added translation and image proxy

This commit is contained in:
Vladislav Khorev 2015-06-27 15:08:58 +00:00
parent f7b2d01a13
commit b648779ba3
35 changed files with 573 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

View File

@ -1,7 +1,15 @@
<?php
// change the following paths if necessary
$yii=dirname(__FILE__).'/../../../yii1.1.15/framework/yii.php';
if (strncasecmp(PHP_OS, 'WIN', 3) == 0)
{
$yii=dirname(__FILE__).'/../../../yii1.1.15/framework/yii.php';
}
else
{
$yii=dirname(__FILE__).'/../../yii1.1.15/framework/yii.php';
}
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following lines when in production mode

View File

@ -3,18 +3,8 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/ChannelController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/PhotoController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/PhotoAlbumRelationController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/VideoController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/VideoChannelRelationController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/ArticleController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/ArticleJournalRelationController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/JournalController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/AlbumController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/ChannelArticleRelationController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/controllers/AlbumArticleRelationController.php</file>
<file>file:/C:/Workplace/Apache2.4/htdocs/bashgid/protected/models/Photo.php</file>
</group>
</open-files>
</project-private>

View File

@ -142,6 +142,11 @@ class PhotoAlbumRelationController extends Controller {
public function actionJson()
{
$dataArray = PhotoAlbumRelation::model()->findAll();
foreach ($dataArray as &$data)
{
$data->imageUrl = "http://bashgid.hallyu.ru/bashgid_images/" . base64_encode($data->imageUrl) . ".jpg";
}
$this->layout = false;
header('Content-type: application/json');

View File

@ -148,6 +148,11 @@ class PhotoController extends Controller {
public function actionJson()
{
$dataArray = Photo::model()->findAll();
foreach ($dataArray as &$data)
{
$data->imageUrl = "http://bashgid.hallyu.ru/bashgid_images/" . base64_encode($data->imageUrl) . ".jpg";
}
$this->layout = false;
header('Content-type: application/json');

View File

@ -0,0 +1,179 @@
<?php
class TranslationController extends Controller
{
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow',
'actions' => array('index', 'view', 'create', 'update', 'admin', 'delete'),
'users' => array('@'),
),
array('allow',
'actions' => array('json'),
'users' => array('*'),
),
array('deny', // deny all users
'users' => array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Translation;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Translation']))
{
$model->attributes=$_POST['Translation'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Translation']))
{
$model->attributes=$_POST['Translation'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Translation');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Translation('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Translation']))
$model->attributes=$_GET['Translation'];
$this->render('admin',array(
'model'=>$model,
));
}
public function actionJson()
{
$dataArray = Translation::model()->findAll();
$this->layout = false;
header('Content-type: application/json');
echo CJavaScript::jsonEncode($dataArray);
Yii::app()->end();
}
/**
* 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.
* @param integer $id the ID of the model to be loaded
* @return Translation the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Translation::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Translation $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='translation-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}

View File

@ -0,0 +1,102 @@
<?php
/**
* This is the model class for table "table_translation".
*
* The followings are the available columns in table 'table_translation':
* @property integer $id
* @property string $name
* @property string $textEn
* @property string $textRu
* @property string $textZh
*/
class Translation extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'table_translation';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('name, textEn, textRu, textZh', 'required'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, name, textEn, textRu, textZh', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'name' => 'Name',
'textEn' => 'Text En',
'textRu' => 'Text Ru',
'textZh' => 'Text Zh',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('textEn',$this->textEn,true);
$criteria->compare('textRu',$this->textRu,true);
$criteria->compare('textZh',$this->textZh,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Translation the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}

View File

@ -24,6 +24,7 @@ $this->widget('zii.widgets.CMenu',array(
array('label' => 'Manage Channel in Article', 'url' => array('channelArticleRelation/admin')),
array('label' => 'Journal', 'url' => array('journal/admin')),
array('label' => 'Manage Article in Journal', 'url' => array('articleJournalRelation/admin')),
array('label' => 'Translation', 'url' => array('translation/admin')),
),
));

View File

@ -0,0 +1,52 @@
<?php
/* @var $this TranslationController */
/* @var $model Translation */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'translation-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textArea($model,'name',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'textEn'); ?>
<?php echo $form->textArea($model,'textEn',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'textEn'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'textRu'); ?>
<?php echo $form->textArea($model,'textRu',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'textRu'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'textZh'); ?>
<?php echo $form->textArea($model,'textZh',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'textZh'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->

View File

@ -0,0 +1,45 @@
<?php
/* @var $this TranslationController */
/* @var $model Translation */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'id'); ?>
<?php echo $form->textField($model,'id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'name'); ?>
<?php echo $form->textArea($model,'name',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'textEn'); ?>
<?php echo $form->textArea($model,'textEn',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'textRu'); ?>
<?php echo $form->textArea($model,'textRu',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'textZh'); ?>
<?php echo $form->textArea($model,'textZh',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->

View File

@ -0,0 +1,29 @@
<?php
/* @var $this TranslationController */
/* @var $data Translation */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>
<?php echo CHtml::encode($data->name); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('textEn')); ?>:</b>
<?php echo CHtml::encode($data->textEn); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('textRu')); ?>:</b>
<?php echo CHtml::encode($data->textRu); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('textZh')); ?>:</b>
<?php echo CHtml::encode($data->textZh); ?>
<br />
</div>

View File

@ -0,0 +1,57 @@
<?php
/* @var $this TranslationController */
/* @var $model Translation */
$this->breadcrumbs=array(
'Translations'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List Translation', 'url'=>array('index')),
array('label'=>'Create Translation', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#translation-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manage Translations</h1>
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'translation-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'name',
'textEn',
'textRu',
'textZh',
array(
'class'=>'CButtonColumn',
),
),
)); ?>

View File

@ -0,0 +1,18 @@
<?php
/* @var $this TranslationController */
/* @var $model Translation */
$this->breadcrumbs=array(
'Translations'=>array('index'),
'Create',
);
$this->menu=array(
array('label'=>'List Translation', 'url'=>array('index')),
array('label'=>'Manage Translation', 'url'=>array('admin')),
);
?>
<h1>Create Translation</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@ -0,0 +1,20 @@
<?php
/* @var $this TranslationController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Translations',
);
$this->menu=array(
array('label'=>'Create Translation', 'url'=>array('create')),
array('label'=>'Manage Translation', 'url'=>array('admin')),
);
?>
<h1>Translations</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>

View File

@ -0,0 +1,21 @@
<?php
/* @var $this TranslationController */
/* @var $model Translation */
$this->breadcrumbs=array(
'Translations'=>array('index'),
$model->name=>array('view','id'=>$model->id),
'Update',
);
$this->menu=array(
array('label'=>'List Translation', 'url'=>array('index')),
array('label'=>'Create Translation', 'url'=>array('create')),
array('label'=>'View Translation', 'url'=>array('view', 'id'=>$model->id)),
array('label'=>'Manage Translation', 'url'=>array('admin')),
);
?>
<h1>Update Translation <?php echo $model->id; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@ -0,0 +1,30 @@
<?php
/* @var $this TranslationController */
/* @var $model Translation */
$this->breadcrumbs=array(
'Translations'=>array('index'),
$model->name,
);
$this->menu=array(
array('label'=>'List Translation', 'url'=>array('index')),
array('label'=>'Create Translation', 'url'=>array('create')),
array('label'=>'Update Translation', 'url'=>array('update', 'id'=>$model->id)),
array('label'=>'Delete Translation', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Translation', 'url'=>array('admin')),
);
?>
<h1>View Translation #<?php echo $model->id; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'name',
'textEn',
'textRu',
'textZh',
),
)); ?>