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,15 +125,19 @@ 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));
}

View File

@ -1,21 +1,16 @@
<?php
class DictionaryForm extends CFormModel {
class DictionaryForm extends CFormModel
{
public $request;
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')),
);
}
@ -25,38 +20,32 @@ class DictionaryForm extends CFormModel
);
}
public function getResponse()
{
public function getResponse() {
$this->serverIsWorking = false;
$this->response = false;
try
{
set_error_handler(function() { /* ignore errors */ });
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)
{
if ($this->jsonString) {
$this->serverIsWorking = true;
}
}
catch(Exception $ex)
{
} catch (Exception $ex) {
$this->serverIsWorking = false;
}
$this->serverIsWorking = true;
}
public function resultExists()
{
public function resultExists() {
return ($this->serverIsWorking) && ($this->response) && ($this->response['words'] !== "");
}
public function getDataProvider()
{
public function getDataProvider() {
$dataProvider = new CArrayDataProvider($this->response['words'], array(
'id' => 'dictionaryResultDataProvider',
'pagination' => array(
@ -66,4 +55,5 @@ class DictionaryForm extends CFormModel
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\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)

View File

@ -12,21 +12,21 @@ $this->pageTitle=Yii::t('app', Yii::app()->name);
<p>
<?php
$wordType = $data["word"];
$wordType = $data["type"];
$nounData = null;
$modificatorsData = null;
$adjectiveData = null;
if ($wordType === "noun")
{
$nounData = $data["noun"];
echo str_replace('{nominative}', $nounData["nominativeSingularForm"], Yii::t('dict', 'Most likely, original word is <b>{nominative}</b><BR>'));
$modificatorsData = $data["modificators"];
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>";
}
if ($wordType === "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>";
}
?>
@ -38,7 +38,7 @@ echo Yii::t('dict', "This is adjective") . "<BR>";
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)) . "<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>";
}
else
{
$combinedStr = $nounData["grammaticalCase"] . "_" . $nounData["count"] . $genderSuffix;
$combinedStr = $modificatorsData["grammaticalCase"] . "_" . $modificatorsData["count"] . $genderSuffix;
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'))); ?>
</div>
<?php echo CHtml::endForm(); ?>
HaH