diff --git a/yii/protected/controllers/SiteController.php b/yii/protected/controllers/SiteController.php index d8a2410..57cabbc 100644 --- a/yii/protected/controllers/SiteController.php +++ b/yii/protected/controllers/SiteController.php @@ -125,14 +125,18 @@ class SiteController extends Controller if($model->validate()) { + $oldPassword = $model->password; $model->password = $this->better_crypt($model->password); - $model->save(); + if ($model->save()) + { //$this->redirect(Yii::app()->user->returnUrl); $this->redirect(array("site/login")); return; + } + $model->password = $oldPassword; } } $this->render('register',array('model'=>$model)); diff --git a/yii/protected/models/DictionaryForm.php b/yii/protected/models/DictionaryForm.php index 92ff919..5e88e55 100644 --- a/yii/protected/models/DictionaryForm.php +++ b/yii/protected/models/DictionaryForm.php @@ -1,69 +1,59 @@ '{attribute} ' . Yii::t('app', 'Field should not be blank')), - - ); - } - - function attributeLabels(){ + public function rules() { return array( - 'request' => Yii::t('app', 'Please enter request:'), + // username and password are required + array('request', 'required', 'message' => '{attribute} ' . Yii::t('app', 'Field should not be blank')), ); } - - public function getResponse() - { - $this->serverIsWorking = false; - $this->response = false; - - try - { - set_error_handler(function() { /* ignore errors */ }); - $this->jsonString = file_get_contents('http://127.0.0.1:8843/' . $this->request); - $this->response = json_decode($this->jsonString, true); - restore_error_handler(); - - if ($this->jsonString) - { - $this->serverIsWorking = true; - } - } - catch(Exception $ex) - { - $this->serverIsWorking = false; - } - - $this->serverIsWorking = true; - } - - public function resultExists() - { - return ($this->serverIsWorking) && ($this->response) && ($this->response['words'] !== ""); - } - - public function getDataProvider() - { - $dataProvider=new CArrayDataProvider($this->response['words'], array( - 'id'=>'dictionaryResultDataProvider', - 'pagination'=>array( - 'pageSize'=>10, - ), - )); - - return $dataProvider; - } + + function attributeLabels() { + return array( + 'request' => Yii::t('app', 'Please enter request:'), + ); + } + + public function getResponse() { + $this->serverIsWorking = false; + $this->response = false; + + try { + set_error_handler(function() { /* ignore errors */ + }); + $this->jsonString = file_get_contents('http://127.0.0.1:8843/' . $this->request); + $this->response = json_decode($this->jsonString, true); + restore_error_handler(); + + if ($this->jsonString) { + $this->serverIsWorking = true; + } + } catch (Exception $ex) { + $this->serverIsWorking = false; + } + + $this->serverIsWorking = true; + } + + public function resultExists() { + return ($this->serverIsWorking) && ($this->response) && ($this->response['words'] !== ""); + } + + public function getDataProvider() { + $dataProvider = new CArrayDataProvider($this->response['words'], array( + 'id' => 'dictionaryResultDataProvider', + 'pagination' => array( + 'pageSize' => 10, + ), + )); + + return $dataProvider; + } + } diff --git a/yii/protected/runtime/application.log b/yii/protected/runtime/application.log index 6f16434..394f3c9 100644 --- a/yii/protected/runtime/application.log +++ b/yii/protected/runtime/application.log @@ -1440,3 +1440,141 @@ REQUEST_URI=/cj/index.php?r=site/dictionary in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php (15) in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (30) in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) +2014/12/13 15:58:31 [error] [php] Undefined index: nominativeSingularForm (C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php:22) +Stack trace: +#0 C:\Workplace\yii1.1.15\framework\zii\widgets\CListView.php(291): SiteController->renderFile() +#1 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(167): CListView->renderItems() +#2 unknown(0): CListView->renderSection() +#3 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(150): preg_replace_callback() +#4 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(135): CListView->renderContent() +#5 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(173): CListView->run() +#6 C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php(30): SiteController->widget() +#7 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(126): require() +#8 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(95): SiteController->renderInternal() +#9 C:\Workplace\yii1.1.15\framework\web\CController.php(869): SiteController->renderFile() +#10 C:\Workplace\yii1.1.15\framework\web\CController.php(782): SiteController->renderPartial() +#11 C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php(69): SiteController->render() +#12 C:\Workplace\yii1.1.15\framework\web\actions\CInlineAction.php(49): SiteController->actionDictionary() +#13 C:\Workplace\yii1.1.15\framework\web\CController.php(308): CInlineAction->runWithParams() +#14 C:\Workplace\yii1.1.15\framework\web\CController.php(286): SiteController->runAction() +#15 C:\Workplace\yii1.1.15\framework\web\CController.php(265): SiteController->runActionWithFilters() +#16 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(282): SiteController->run() +#17 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(141): CWebApplication->runController() +#18 C:\Workplace\yii1.1.15\framework\base\CApplication.php(180): CWebApplication->processRequest() +#19 C:\Workplace\Apache2.4\htdocs\cj\index.php(25): CWebApplication->run() +REQUEST_URI=/cj/index.php?r=site/dictionary +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php (22) +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (30) +in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) +2014/12/13 16:15:09 [error] [php] Array to string conversion (C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php:13) +Stack trace: +#0 C:\Workplace\yii1.1.15\framework\web\CController.php(869): SiteController->renderFile() +#1 C:\Workplace\yii1.1.15\framework\web\CController.php(782): SiteController->renderPartial() +#2 C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php(69): SiteController->render() +#3 C:\Workplace\yii1.1.15\framework\web\actions\CInlineAction.php(49): SiteController->actionDictionary() +#4 C:\Workplace\yii1.1.15\framework\web\CController.php(308): CInlineAction->runWithParams() +#5 C:\Workplace\yii1.1.15\framework\web\CController.php(286): SiteController->runAction() +#6 C:\Workplace\yii1.1.15\framework\web\CController.php(265): SiteController->runActionWithFilters() +#7 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(282): SiteController->run() +#8 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(141): CWebApplication->runController() +#9 C:\Workplace\yii1.1.15\framework\base\CApplication.php(180): CWebApplication->processRequest() +#10 C:\Workplace\Apache2.4\htdocs\cj\index.php(25): CWebApplication->run() +REQUEST_URI=/cj/index.php?r=site/dictionary +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (13) +in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) +in C:\Workplace\Apache2.4\htdocs\cj\index.php (25) +2014/12/13 16:15:28 [error] [php] Array to string conversion (C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php:14) +Stack trace: +#0 C:\Workplace\yii1.1.15\framework\web\CController.php(869): SiteController->renderFile() +#1 C:\Workplace\yii1.1.15\framework\web\CController.php(782): SiteController->renderPartial() +#2 C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php(69): SiteController->render() +#3 C:\Workplace\yii1.1.15\framework\web\actions\CInlineAction.php(49): SiteController->actionDictionary() +#4 C:\Workplace\yii1.1.15\framework\web\CController.php(308): CInlineAction->runWithParams() +#5 C:\Workplace\yii1.1.15\framework\web\CController.php(286): SiteController->runAction() +#6 C:\Workplace\yii1.1.15\framework\web\CController.php(265): SiteController->runActionWithFilters() +#7 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(282): SiteController->run() +#8 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(141): CWebApplication->runController() +#9 C:\Workplace\yii1.1.15\framework\base\CApplication.php(180): CWebApplication->processRequest() +#10 C:\Workplace\Apache2.4\htdocs\cj\index.php(25): CWebApplication->run() +REQUEST_URI=/cj/index.php?r=site/dictionary +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (14) +in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) +in C:\Workplace\Apache2.4\htdocs\cj\index.php (25) +2014/12/13 16:17:46 [error] [php] Undefined index: animated (C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php:41) +Stack trace: +#0 C:\Workplace\yii1.1.15\framework\zii\widgets\CListView.php(291): SiteController->renderFile() +#1 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(167): CListView->renderItems() +#2 unknown(0): CListView->renderSection() +#3 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(150): preg_replace_callback() +#4 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(135): CListView->renderContent() +#5 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(173): CListView->run() +#6 C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php(30): SiteController->widget() +#7 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(126): require() +#8 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(95): SiteController->renderInternal() +#9 C:\Workplace\yii1.1.15\framework\web\CController.php(869): SiteController->renderFile() +#10 C:\Workplace\yii1.1.15\framework\web\CController.php(782): SiteController->renderPartial() +#11 C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php(69): SiteController->render() +#12 C:\Workplace\yii1.1.15\framework\web\actions\CInlineAction.php(49): SiteController->actionDictionary() +#13 C:\Workplace\yii1.1.15\framework\web\CController.php(308): CInlineAction->runWithParams() +#14 C:\Workplace\yii1.1.15\framework\web\CController.php(286): SiteController->runAction() +#15 C:\Workplace\yii1.1.15\framework\web\CController.php(265): SiteController->runActionWithFilters() +#16 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(282): SiteController->run() +#17 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(141): CWebApplication->runController() +#18 C:\Workplace\yii1.1.15\framework\base\CApplication.php(180): CWebApplication->processRequest() +#19 C:\Workplace\Apache2.4\htdocs\cj\index.php(25): CWebApplication->run() +REQUEST_URI=/cj/index.php?r=site/dictionary +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php (41) +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (30) +in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) +2014/12/13 16:33:06 [error] [php] Undefined index: modificators (C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php:21) +Stack trace: +#0 C:\Workplace\yii1.1.15\framework\zii\widgets\CListView.php(291): SiteController->renderFile() +#1 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(167): CListView->renderItems() +#2 unknown(0): CListView->renderSection() +#3 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(150): preg_replace_callback() +#4 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(135): CListView->renderContent() +#5 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(173): CListView->run() +#6 C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php(30): SiteController->widget() +#7 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(126): require() +#8 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(95): SiteController->renderInternal() +#9 C:\Workplace\yii1.1.15\framework\web\CController.php(869): SiteController->renderFile() +#10 C:\Workplace\yii1.1.15\framework\web\CController.php(782): SiteController->renderPartial() +#11 C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php(69): SiteController->render() +#12 C:\Workplace\yii1.1.15\framework\web\actions\CInlineAction.php(49): SiteController->actionDictionary() +#13 C:\Workplace\yii1.1.15\framework\web\CController.php(308): CInlineAction->runWithParams() +#14 C:\Workplace\yii1.1.15\framework\web\CController.php(286): SiteController->runAction() +#15 C:\Workplace\yii1.1.15\framework\web\CController.php(265): SiteController->runActionWithFilters() +#16 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(282): SiteController->run() +#17 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(141): CWebApplication->runController() +#18 C:\Workplace\yii1.1.15\framework\base\CApplication.php(180): CWebApplication->processRequest() +#19 C:\Workplace\Apache2.4\htdocs\cj\index.php(25): CWebApplication->run() +REQUEST_URI=/cj/index.php?r=site/dictionary +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php (21) +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (30) +in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) +2014/12/13 16:33:53 [error] [php] Undefined variable: modificators (C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php:51) +Stack trace: +#0 C:\Workplace\yii1.1.15\framework\zii\widgets\CListView.php(291): SiteController->renderFile() +#1 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(167): CListView->renderItems() +#2 unknown(0): CListView->renderSection() +#3 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(150): preg_replace_callback() +#4 C:\Workplace\yii1.1.15\framework\zii\widgets\CBaseListView.php(135): CListView->renderContent() +#5 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(173): CListView->run() +#6 C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php(30): SiteController->widget() +#7 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(126): require() +#8 C:\Workplace\yii1.1.15\framework\web\CBaseController.php(95): SiteController->renderInternal() +#9 C:\Workplace\yii1.1.15\framework\web\CController.php(869): SiteController->renderFile() +#10 C:\Workplace\yii1.1.15\framework\web\CController.php(782): SiteController->renderPartial() +#11 C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php(69): SiteController->render() +#12 C:\Workplace\yii1.1.15\framework\web\actions\CInlineAction.php(49): SiteController->actionDictionary() +#13 C:\Workplace\yii1.1.15\framework\web\CController.php(308): CInlineAction->runWithParams() +#14 C:\Workplace\yii1.1.15\framework\web\CController.php(286): SiteController->runAction() +#15 C:\Workplace\yii1.1.15\framework\web\CController.php(265): SiteController->runActionWithFilters() +#16 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(282): SiteController->run() +#17 C:\Workplace\yii1.1.15\framework\web\CWebApplication.php(141): CWebApplication->runController() +#18 C:\Workplace\yii1.1.15\framework\base\CApplication.php(180): CWebApplication->processRequest() +#19 C:\Workplace\Apache2.4\htdocs\cj\index.php(25): CWebApplication->run() +REQUEST_URI=/cj/index.php?r=site/dictionary +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\_dictionaryResultView.php (51) +in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (30) +in C:\Workplace\Apache2.4\htdocs\cj\protected\controllers\SiteController.php (69) diff --git a/yii/protected/views/site/_dictionaryResultView.php b/yii/protected/views/site/_dictionaryResultView.php index 1de7bd5..a30f496 100644 --- a/yii/protected/views/site/_dictionaryResultView.php +++ b/yii/protected/views/site/_dictionaryResultView.php @@ -12,21 +12,21 @@ $this->pageTitle=Yii::t('app', Yii::app()->name);

{nominative}
')); +$modificatorsData = $data["modificators"]; +echo str_replace('{nominative}', $data["word"], Yii::t('dict', 'Most likely, original word is {nominative}
')); echo Yii::t('dict', "This is noun") . "
"; } if ($wordType === "adjective") { $adjectiveData = $data["adjective"]; -echo str_replace('{nominative}', $adjectiveData["nominativeSingularForm"], Yii::t('dict', 'Most likely, original word is {nominative}
')); +echo str_replace('{nominative}', $data["word"], Yii::t('dict', 'Most likely, original word is {nominative}
')); echo Yii::t('dict', "This is adjective") . "
"; } ?> @@ -38,7 +38,7 @@ echo Yii::t('dict', "This is adjective") . "
"; if ($wordType === "noun") { $animateSuffix = ""; -if ($nounData["animated"] === "true") +if ($modificatorsData["animated"] === "true") { $animateSuffix = "ANIMATE"; } @@ -48,13 +48,13 @@ else } $genderSuffix = ""; -if ($nounData["count"] === "NC_SINGULAR") +if ($modificatorsData["count"] === "NC_SINGULAR") { - if ($nounData["gender"] === "0") + if ($modificatorsData["gender"] === "0") { $genderSuffix = "_MALE"; } - else if ($nounData["gender"] === "1") + else if ($modificatorsData["gender"] === "1") { $genderSuffix = "_FEMALE"; } @@ -66,21 +66,21 @@ if ($nounData["count"] === "NC_SINGULAR") -if ($nounData["grammaticalCase"] === "NGC_P4_ACCUSATIVE") +if ($modificatorsData["grammaticalCase"] === "NGC_P4_ACCUSATIVE") { - $combinedStr = $nounData["grammaticalCase"] . "_" . $nounData["count"] . "_" . $animateSuffix . $genderSuffix; + $combinedStr = $modificatorsData["grammaticalCase"] . "_" . $modificatorsData["count"] . "_" . $animateSuffix . $genderSuffix; echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "
"; } -else if ($nounData["grammaticalCase"] === "NGC_P1_NOMINATIVE") +else if ($modificatorsData["grammaticalCase"] === "NGC_P1_NOMINATIVE") { - $combinedStr = $nounData["grammaticalCase"] . "_" . $nounData["count"] . $genderSuffix; + $combinedStr = $modificatorsData["grammaticalCase"] . "_" . $modificatorsData["count"] . $genderSuffix; echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "
"; } else { - $combinedStr = $nounData["grammaticalCase"] . "_" . $nounData["count"] . $genderSuffix; + $combinedStr = $modificatorsData["grammaticalCase"] . "_" . $modificatorsData["count"] . $genderSuffix; echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "
"; } diff --git a/yii/protected/views/site/langBox.php b/yii/protected/views/site/langBox.php index a920e19..088baba 100644 --- a/yii/protected/views/site/langBox.php +++ b/yii/protected/views/site/langBox.php @@ -5,3 +5,4 @@ 'en' => 'English', 'ru' => 'Русский', 'cn' => '中文'), array('submit' => array('site/index'))); ?> +HaH \ No newline at end of file