Commit 0a811f75 by Junaid Rahman pv

added file editor option

parent 16402987
......@@ -131,7 +131,6 @@ class ThemeController extends Controller
}
}
public function actionFiles($id)
{
$model = $this->findModel($id);
......
......@@ -14,23 +14,6 @@ class ThemeFileController extends \yii\web\Controller
{
return $this->render('index');
}
/**
* Finds the Theme model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Theme the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = ThemeFiles::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
public function actionUpload()
{
$model = new ThemeFiles();
......@@ -58,4 +41,24 @@ class ThemeFileController extends \yii\web\Controller
return $this->redirect(['theme/index']);
}
public function actionEditor($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post())) {
}
return $this->render('editor',[
'model' => $model,
]);
}
protected function findModel($id)
{
if (($model = ThemeFiles::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
......@@ -4,17 +4,15 @@
?>
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\bootstrap\Modal;
use yii\helpers\Url;
?>
<div class="customer-form">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<table>
<table class="table">
<tr>
<th>File Name</th>
<th>Options</th>
......@@ -30,22 +28,33 @@ use yii\helpers\Url;
$fileCode = $value['code'];
$modelFiles[0]->theme_code = $themeCode;
$modelFiles[0]->file_code = $fileCode;
if ($modelFiles[0]::isFileExist($themeCode, $fileCode)) { ?>
if ($modelFiles[0]::isFileExist($themeCode, $fileCode)) {
$fileModel = $modelFiles[0]::findOne([
'theme_code' => $themeCode,
'file_code' => $fileCode
]);
?>
<td>
<td><?= 'edit' ?></td>
<?= Html::a(' Edit ', ['theme-file/editor', 'id' => $fileModel->id], [
'class' => 'btn btn-primary fa fa-edit',
]) ?>
</td>
<?php } else { ?>
<td>
<?= Html::button('Upload File', [
'class' => 'btn btn-default',
'class' => 'btn btn-primary',
'id' => 'modalButton' . $value['id'],
'onclick' => 'uploadJquery.upload(' . $value['id'] . ');'
]) ?>
<?php
Modal::begin([
'header' => '<h3>Upload</h3>',
'header' => '',
'id' => 'modal' . $value['id'],
'size' => 'modal-sm',
//keeps from closing modal with esc key or by clicking out of the modal.
......@@ -54,18 +63,13 @@ use yii\helpers\Url;
?>
<div id='modalContent' .<?= $value['id'] ?> style="text-align: center">
<div id='modalContent'<?= $value['id'] ?> style="text-align: center">
<?= $this->render('upload', [
'model' => $modelFiles[0],
]) ?>
<?= $this->render('upload', ['model' => $modelFiles[0],]) ?>
</div>
<?php
yii\bootstrap\Modal::end();
?>
<?php yii\bootstrap\Modal::end(); ?>
</td>
......
<?php
/**
* Created by PhpStorm.
* User: user50
* Date: 22-09-2016
* Time: 02:37 PM
*/
use yii\widgets\ActiveForm;
use yii\helpers\Html;
?>
<div class="text-block-form">
<?php $form = ActiveForm::begin(); ?>
<?php
$file = yii::getAlias('@storage/private/theme-assets/') .$model->theme_code . '/' .$model->file_code;
$model->fileContent = file_get_contents($file);
?>
?>
<?= $form->field($model, 'fileContent')->widget(
trntv\aceeditor\AceEditor::className(),
[
'mode' => 'html'
]
) ?>
<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'),
['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
......@@ -19,7 +19,7 @@ use yii\bootstrap\Html;
'action' => '../theme-file/upload'
]); ?>
<div class="conatiner">
<div class="panel">
<div class="row">
<div class="col-md-11">
......@@ -43,7 +43,7 @@ use yii\bootstrap\Html;
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('backend', 'Upload'),
<?= Html::submitButton(Yii::t('backend', 'Save'),
['class' => 'btn btn-primary']) ?>
</div>
......
......@@ -22,4 +22,5 @@ body {
padding-left: 10px;
}
}
\ No newline at end of file
......@@ -26,6 +26,10 @@ class ThemeFiles extends \yii\db\ActiveRecord
* @var file upload
*/
public $file;
/*
* @var file upload
*/
public $fileContent;
/**
* @inheritdoc
*/
......@@ -51,7 +55,7 @@ class ThemeFiles extends \yii\db\ActiveRecord
{
return [
[['theme_code', 'file_code','file'], 'required'],
[['theme_code', 'file_code'], 'string'],
[['theme_code', 'file_code','fileContent'], 'string'],
[['created_at', 'updated_at'], 'integer'],
[['file_code'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryFiles::className(), 'targetAttribute' => ['file_code' => 'id']],
[['theme_code'], 'exist', 'skipOnError' => true, 'targetClass' => Theme::className(), 'targetAttribute' => ['theme_code' => 'id']],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment