web access very cool
This commit is contained in:
1 parent
760ddd06ee
commit
482fb1edc4
51 files changed
+1780
-350
No files matched your search
@@ -28,7 +28,7 @@ class JournalController extends Controller {
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'actions' => array('index', 'view', 'create', 'update', 'admin', 'delete'),
|
||||
'actions' => array('index', 'view', 'create', 'update', 'admin', 'delete', 'addMax', 'editMax', 'editArticlesMax'),
|
||||
'users' => array('@'),
|
||||
),
|
||||
array('allow',
|
||||
@@ -149,6 +149,100 @@ class JournalController extends Controller {
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
public function actionAddMax()
|
||||
{
|
||||
$model = new JournalMaxForm;
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['JournalMaxForm']))
|
||||
{
|
||||
|
||||
$model->attributes = $_POST['JournalMaxForm'];
|
||||
|
||||
|
||||
|
||||
if ($this->saveJournalForm($model))
|
||||
{
|
||||
$this->redirect(array('editArticlesMax'));
|
||||
} else
|
||||
{
|
||||
$this->redirect(array('editMax'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$this->render('addMax', array(
|
||||
'model' => $model,
|
||||
));
|
||||
}
|
||||
|
||||
public function actionEditMax()
|
||||
{
|
||||
|
||||
$model = new JournalMaxForm;
|
||||
|
||||
if (isset($_POST['JournalMaxForm']))
|
||||
{
|
||||
$model->attributes = $_POST['JournalMaxForm'];
|
||||
|
||||
if ($this->saveJournalForm($model))
|
||||
{
|
||||
$this->redirect(array('editArticlesMax'));
|
||||
} else
|
||||
{
|
||||
$this->redirect(array('editMax'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$currentJournal = Journal::getCurrentUserJournal();
|
||||
if ($currentJournal)
|
||||
{
|
||||
$titleTranslationModel = Translation::model()->find('name=:name', array(':name' => Yii::app()->user->name . '_journal_title_translation'));
|
||||
if ($titleTranslationModel)
|
||||
{
|
||||
$model->titleRu = $titleTranslationModel->textRu;
|
||||
$model->titleEn = $titleTranslationModel->textEn;
|
||||
$model->titleZh = $titleTranslationModel->textZh;
|
||||
}
|
||||
|
||||
$descriptionTranslationModel = Translation::model()->find('name=:name', array(':name' => Yii::app()->user->name . '_journal_description_translation'));
|
||||
if ($descriptionTranslationModel)
|
||||
{
|
||||
$model->descriptionRu = $descriptionTranslationModel->textRu;
|
||||
$model->descriptionEn = $descriptionTranslationModel->textEn;
|
||||
$model->descriptionZh = $descriptionTranslationModel->textZh;
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('editMax', array(
|
||||
'model' => $model,
|
||||
));
|
||||
}
|
||||
|
||||
public function actionEditArticlesMax()
|
||||
{
|
||||
|
||||
$articleNameArr = ArticleJournalRelation::model()->findAll('journalName=:journalName', array(':journalName' => Yii::app()->user->name . '_journal'));
|
||||
|
||||
|
||||
$articleArr = array();
|
||||
foreach ($articleNameArr as $articleRelation)
|
||||
{
|
||||
$article = Article::model()->find('name=:name', array(':name' => $articleRelation->articleName));
|
||||
$article->title = Translation::model()->find('name=:name', array(':name' => $article->title))->textRu;
|
||||
|
||||
$articleArr[] = $article;
|
||||
}
|
||||
|
||||
$this->render('editArticlesMax', array(
|
||||
'articleArr' => $articleArr,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data model based on the primary key given in the GET variable.
|
||||
* If the data model is not found, an HTTP exception will be raised.
|
||||
@@ -177,4 +271,67 @@ class JournalController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveJournalForm($model)
|
||||
{
|
||||
|
||||
if (empty($model->titleEn))
|
||||
{
|
||||
$model->titleEn = 'NEED_TRANSLATION';
|
||||
}
|
||||
if (empty($model->titleZh))
|
||||
{
|
||||
$model->titleZh = 'NEED_TRANSLATION';
|
||||
}
|
||||
if (empty($model->descriptionEn))
|
||||
{
|
||||
$model->descriptionEn = 'NEED_TRANSLATION';
|
||||
}
|
||||
if (empty($model->descriptionZh))
|
||||
{
|
||||
$model->descriptionZh = 'NEED_TRANSLATION';
|
||||
}
|
||||
|
||||
$journalModel = Journal::getCurrentUserJournal();
|
||||
|
||||
if (!Journal::getCurrentUserJournal())
|
||||
{
|
||||
|
||||
$journalModel = new Journal;
|
||||
}
|
||||
|
||||
$journalModel->name = Yii::app()->user->name . '_journal';
|
||||
$journalModel->title = Yii::app()->user->name . '_journal_title_translation';
|
||||
$journalModel->description = Yii::app()->user->name . '_journal_description_translation';
|
||||
|
||||
|
||||
$titleTranslationModel = Translation::model()->find('name=:name', array(':name' => Yii::app()->user->name . '_journal_title_translation'));
|
||||
if ($titleTranslationModel === null)
|
||||
{
|
||||
$titleTranslationModel = new Translation;
|
||||
}
|
||||
|
||||
$titleTranslationModel->name = Yii::app()->user->name . '_journal_title_translation';
|
||||
$titleTranslationModel->textRu = $model->titleRu;
|
||||
$titleTranslationModel->textEn = $model->titleEn;
|
||||
$titleTranslationModel->textZh = $model->titleZh;
|
||||
$titleTranslationModel->save();
|
||||
|
||||
|
||||
$descriptionTranslationModel = Translation::model()->find('name=:name', array(':name' => Yii::app()->user->name . '_journal_description_translation'));
|
||||
if ($descriptionTranslationModel === null)
|
||||
{
|
||||
$descriptionTranslationModel = new Translation;
|
||||
}
|
||||
|
||||
|
||||
$descriptionTranslationModel->name = Yii::app()->user->name . '_journal_description_translation';
|
||||
$descriptionTranslationModel->textRu = $model->descriptionRu;
|
||||
$descriptionTranslationModel->textEn = $model->descriptionEn;
|
||||
$descriptionTranslationModel->textZh = $model->descriptionZh;
|
||||
$descriptionTranslationModel->save();
|
||||
|
||||
|
||||
return $journalModel->save();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user