minor changes

This commit is contained in:
Vladislav Khorev 2015-01-20 20:48:23 +00:00
parent 6f57762c59
commit 834f92267c
5 changed files with 209 additions and 76 deletions

View File

@ -125,14 +125,18 @@ class SiteController extends Controller
if($model->validate()) if($model->validate())
{ {
$oldPassword = $model->password;
$model->password = $this->better_crypt($model->password); $model->password = $this->better_crypt($model->password);
$model->save(); if ($model->save())
{
//$this->redirect(Yii::app()->user->returnUrl); //$this->redirect(Yii::app()->user->returnUrl);
$this->redirect(array("site/login")); $this->redirect(array("site/login"));
return; return;
}
$model->password = $oldPassword;
} }
} }
$this->render('register',array('model'=>$model)); $this->render('register',array('model'=>$model));

View File

@ -1,69 +1,59 @@
<?php <?php
class DictionaryForm extends CFormModel {
class DictionaryForm extends CFormModel public $request;
{ public $serverIsWorking;
public $request; public $jsonString;
public $response;
public $serverIsWorking;
public $jsonString;
public $response;
public function rules() public function rules() {
{
return array(
// username and password are required
array('request', 'required', 'message'=>'{attribute} ' . Yii::t('app', 'Field should not be blank')),
);
}
function attributeLabels(){
return array( 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() function attributeLabels() {
{ return array(
$this->serverIsWorking = false; 'request' => Yii::t('app', 'Please enter request:'),
$this->response = false; );
}
try
{ public function getResponse() {
set_error_handler(function() { /* ignore errors */ }); $this->serverIsWorking = false;
$this->jsonString = file_get_contents('http://127.0.0.1:8843/' . $this->request); $this->response = false;
$this->response = json_decode($this->jsonString, true);
restore_error_handler(); try {
set_error_handler(function() { /* ignore errors */
if ($this->jsonString) });
{ $this->jsonString = file_get_contents('http://127.0.0.1:8843/' . $this->request);
$this->serverIsWorking = true; $this->response = json_decode($this->jsonString, true);
} restore_error_handler();
}
catch(Exception $ex) if ($this->jsonString) {
{ $this->serverIsWorking = true;
$this->serverIsWorking = false; }
} } catch (Exception $ex) {
$this->serverIsWorking = false;
$this->serverIsWorking = true; }
}
$this->serverIsWorking = true;
public function resultExists() }
{
return ($this->serverIsWorking) && ($this->response) && ($this->response['words'] !== ""); public function resultExists() {
} return ($this->serverIsWorking) && ($this->response) && ($this->response['words'] !== "");
}
public function getDataProvider()
{ public function getDataProvider() {
$dataProvider=new CArrayDataProvider($this->response['words'], array( $dataProvider = new CArrayDataProvider($this->response['words'], array(
'id'=>'dictionaryResultDataProvider', 'id' => 'dictionaryResultDataProvider',
'pagination'=>array( 'pagination' => array(
'pageSize'=>10, 'pageSize' => 10,
), ),
)); ));
return $dataProvider; return $dataProvider;
} }
} }

View File

@ -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\_dictionaryResultView.php (15)
in C:\Workplace\Apache2.4\htdocs\cj\protected\views\site\dictionaryResult.php (30) 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) 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)

View File

@ -12,21 +12,21 @@ $this->pageTitle=Yii::t('app', Yii::app()->name);
<p> <p>
<?php <?php
$wordType = $data["word"]; $wordType = $data["type"];
$nounData = null; $modificatorsData = null;
$adjectiveData = null; $adjectiveData = null;
if ($wordType === "noun") if ($wordType === "noun")
{ {
$nounData = $data["noun"]; $modificatorsData = $data["modificators"];
echo str_replace('{nominative}', $nounData["nominativeSingularForm"], Yii::t('dict', 'Most likely, original word is <b>{nominative}</b><BR>')); echo str_replace('{nominative}', $data["word"], Yii::t('dict', 'Most likely, original word is <b>{nominative}</b><BR>'));
echo Yii::t('dict', "This is noun") . "<BR>"; echo Yii::t('dict', "This is noun") . "<BR>";
} }
if ($wordType === "adjective") if ($wordType === "adjective")
{ {
$adjectiveData = $data["adjective"]; $adjectiveData = $data["adjective"];
echo str_replace('{nominative}', $adjectiveData["nominativeSingularForm"], Yii::t('dict', 'Most likely, original word is <b>{nominative}</b><BR>')); echo str_replace('{nominative}', $data["word"], Yii::t('dict', 'Most likely, original word is <b>{nominative}</b><BR>'));
echo Yii::t('dict', "This is adjective") . "<BR>"; echo Yii::t('dict', "This is adjective") . "<BR>";
} }
?> ?>
@ -38,7 +38,7 @@ echo Yii::t('dict', "This is adjective") . "<BR>";
if ($wordType === "noun") if ($wordType === "noun")
{ {
$animateSuffix = ""; $animateSuffix = "";
if ($nounData["animated"] === "true") if ($modificatorsData["animated"] === "true")
{ {
$animateSuffix = "ANIMATE"; $animateSuffix = "ANIMATE";
} }
@ -48,13 +48,13 @@ else
} }
$genderSuffix = ""; $genderSuffix = "";
if ($nounData["count"] === "NC_SINGULAR") if ($modificatorsData["count"] === "NC_SINGULAR")
{ {
if ($nounData["gender"] === "0") if ($modificatorsData["gender"] === "0")
{ {
$genderSuffix = "_MALE"; $genderSuffix = "_MALE";
} }
else if ($nounData["gender"] === "1") else if ($modificatorsData["gender"] === "1")
{ {
$genderSuffix = "_FEMALE"; $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)) . "<BR>"; echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "<BR>";
} }
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)) . "<BR>"; echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "<BR>";
} }
else else
{ {
$combinedStr = $nounData["grammaticalCase"] . "_" . $nounData["count"] . $genderSuffix; $combinedStr = $modificatorsData["grammaticalCase"] . "_" . $modificatorsData["count"] . $genderSuffix;
echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "<BR>"; echo str_replace('{noun}', $request, Yii::t('dict', $combinedStr)) . "<BR>";
} }

View File

@ -5,3 +5,4 @@
'en' => 'English', 'ru' => 'Русский', 'cn' => '中文'), array('submit' => array('site/index'))); ?> 'en' => 'English', 'ru' => 'Русский', 'cn' => '中文'), array('submit' => array('site/index'))); ?>
</div> </div>
<?php echo CHtml::endForm(); ?> <?php echo CHtml::endForm(); ?>
HaH