Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
test-project
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Junaid Rahman pv
test-project
Commits
c1b3cfd2
Commit
c1b3cfd2
authored
Sep 21, 2016
by
Junaid Rahman pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edited theme module
parent
010258b8
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
213 additions
and
153 deletions
+213
-153
BackendAsset.php
backend/assets/BackendAsset.php
+2
-1
ThemeController.php
backend/modules/theme/controllers/ThemeController.php
+40
-79
ThemeFileController.php
backend/modules/theme/controllers/ThemeFileController.php
+64
-0
_form.php
backend/modules/theme/views/theme-file/_form.php
+42
-5
index.php
backend/modules/theme/views/theme-file/index.php
+9
-0
upload.php
backend/modules/theme/views/theme-file/upload.php
+36
-0
file.php
backend/modules/theme/views/theme/file.php
+1
-1
index.php
backend/modules/theme/views/theme_file/index.php
+0
-53
main.js
backend/web/js/main.js
+14
-0
m160903_101233_theme.php
common/migrations/db/m160903_101233_theme.php
+0
-2
Theme.php
common/models/Theme.php
+0
-11
ThemeFiles.php
common/models/ThemeFiles.php
+5
-1
No files found.
backend/assets/BackendAsset.php
View file @
c1b3cfd2
...
@@ -19,7 +19,8 @@ class BackendAsset extends AssetBundle
...
@@ -19,7 +19,8 @@ class BackendAsset extends AssetBundle
'css/style.css'
'css/style.css'
];
];
public
$js
=
[
public
$js
=
[
'js/app.js'
'js/app.js'
,
'js/main.js'
];
];
public
$depends
=
[
public
$depends
=
[
...
...
backend/modules/theme/controllers/ThemeController.php
View file @
c1b3cfd2
...
@@ -13,7 +13,6 @@ use yii\helpers\ArrayHelper;
...
@@ -13,7 +13,6 @@ use yii\helpers\ArrayHelper;
use
common\models\Model
;
use
common\models\Model
;
use
yii\httpclient\Response
;
use
yii\httpclient\Response
;
use
yii\widgets\ActiveForm
;
use
yii\widgets\ActiveForm
;
use
app\models\UploadForm
;
use
yii\web\UploadedFile
;
use
yii\web\UploadedFile
;
/**
/**
...
@@ -140,71 +139,48 @@ class ThemeController extends Controller
...
@@ -140,71 +139,48 @@ class ThemeController extends Controller
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
//&& $model->save()
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
//&& $model->save()
// $oldIDs = ArrayHelper::map($modelFiles, 'id', 'id');
$oldIDs
=
ArrayHelper
::
map
(
$modelFiles
,
'id'
,
'id'
);
// $modelFiles = Model::createMultiple(ThemeFiles::classname(), $modelFiles);
$modelFiles
=
Model
::
createMultiple
(
ThemeFiles
::
classname
(),
$modelFiles
);
// Model::loadMultiple($modelFiles, Yii::$app->request->post());
Model
::
loadMultiple
(
$modelFiles
,
Yii
::
$app
->
request
->
post
());
// $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelFiles, 'id', 'id')));
$deletedIDs
=
array_diff
(
$oldIDs
,
array_filter
(
ArrayHelper
::
map
(
$modelFiles
,
'id'
,
'id'
)));
//
// // ajax validation
// ajax validation
// if (Yii::$app->request->isAjax) {
if
(
Yii
::
$app
->
request
->
isAjax
)
{
// Yii::$app->response->format = Response::FORMAT_JSON;
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
// return ArrayHelper::merge(
return
ArrayHelper
::
merge
(
// ActiveForm::validateMultiple($modelFiles),
ActiveForm
::
validateMultiple
(
$modelFiles
),
// ActiveForm::validate($model)
ActiveForm
::
validate
(
$model
)
// );
);
// }
}
//
// // validate all models
// validate all models
// $valid = $model->validate();
$valid
=
$model
->
validate
();
// $valid = Model::validateMultiple($modelFiles) && $valid;
$valid
=
Model
::
validateMultiple
(
$modelFiles
)
&&
$valid
;
//
// if ($valid) {
if
(
$valid
)
{
// $transaction = \Yii::$app->db->beginTransaction();
$transaction
=
\Yii
::
$app
->
db
->
beginTransaction
();
// try {
try
{
// if ($flag = $model->save(false)) {
if
(
$flag
=
$model
->
save
(
false
))
{
// if (! empty($deletedIDs)) {
if
(
!
empty
(
$deletedIDs
))
{
// ThemeFiles::deleteAll(['id' => $deletedIDs]);
ThemeFiles
::
deleteAll
([
'id'
=>
$deletedIDs
]);
// }
}
// foreach ($modelFiles as $modelFiles) {
foreach
(
$modelFiles
as
$modelFiles
)
{
// $modelFiles->customer_id = $model->id;
$modelFiles
->
customer_id
=
$model
->
id
;
// if (! ($flag = $modelFiles->save(false))) {
if
(
!
(
$flag
=
$modelFiles
->
save
(
false
)))
{
// $transaction->rollBack();
$transaction
->
rollBack
();
// break;
break
;
// }
}
// }
}
// }
}
// if ($flag) {
if
(
$flag
)
{
// $transaction->commit();
$transaction
->
commit
();
// return $this->redirect(['files', 'id' => $model->id]);
return
$this
->
redirect
([
'files'
,
'id'
=>
$model
->
id
]);
// }
}
// } catch (Exception $e) {
}
catch
(
Exception
$e
)
{
// $transaction->rollBack();
$transaction
->
rollBack
();
// }
// }
// get the uploaded file instance. for multiple file uploads
// the following data will return an array
$theme_file
=
UploadedFile
::
getInstance
(
$model
,
'theme_file'
);
// the path to save file, you can set an uploadPath
// in Yii::$app->params (as used in example below)
$path
=
$model
->
file
;
if
(
$path
){
echo
'a'
;
if
(
$model
->
save
()){
$theme_file
->
saveAs
(
$path
);
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
// error in saving model
}
}
}
else
{
echo
'aaa'
;
echo
$model
->
file
;
exit
();
}
}
}
}
...
@@ -269,21 +245,6 @@ class ThemeController extends Controller
...
@@ -269,21 +245,6 @@ class ThemeController extends Controller
'modelFiles'
=>
(
empty
(
$modelFiles
))
?
[
new
ThemeFiles
()]
:
$modelFiles
'modelFiles'
=>
(
empty
(
$modelFiles
))
?
[
new
ThemeFiles
()]
:
$modelFiles
]);
]);
}
}
// public function actionUpload()
// {
// $model = new UploadForm();
//
// if (Yii::$app->request->isPost) {
// $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
// if ($model->upload()) {
// echo 'file is uploaded successfully';
// return true;
// }
// }
//
// return $this->render('file', ['model' => $model]);
// }
protected
function
findCategoryFiles
(
$id
){
protected
function
findCategoryFiles
(
$id
){
$fileDetails
=
Yii
::
$app
->
db
->
createCommand
(
'SELECT * FROM lw_category_files WHERE category_id='
.
$id
)
$fileDetails
=
Yii
::
$app
->
db
->
createCommand
(
'SELECT * FROM lw_category_files WHERE category_id='
.
$id
)
...
...
backend/modules/theme/controllers/ThemeFileController.php
0 → 100644
View file @
c1b3cfd2
<?php
namespace
backend\modules\theme\controllers
;
use
yii
;
use
common\models\Theme
;
use
yii\web\NotFoundHttpException
;
use
yii\web\UploadedFile
;
class
ThemeFileController
extends
\yii\web\Controller
{
public
function
actionIndex
()
{
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
=
Theme
::
findOne
(
$id
))
!==
null
)
{
return
$model
;
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
public
function
actionUpload
(
$id
){
$model
=
$this
->
findModel
(
$id
);
$modelFiles
=
$model
->
themeFiles
;
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
//&& $model->save()
// get the uploaded file instance. for multiple file uploads
// the following data will return an array
$theme_file
=
UploadedFile
::
getInstance
(
$model
,
'theme-file'
);
// the path to save file, you can set an uploadPath
$path
=
$model
->
file
;
if
(
$path
)
{
echo
'a'
;
if
(
$model
->
save
())
{
$theme_file
->
saveAs
(
$path
);
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
// error in saving model
}
}
else
{
echo
'aaa'
;
echo
$theme_file
->
id
;
exit
();
}
}
return
$this
->
render
(
'upload'
);
}
}
backend/modules/theme/views/theme
_
file/_form.php
→
backend/modules/theme/views/theme
-
file/_form.php
View file @
c1b3cfd2
...
@@ -5,12 +5,14 @@
...
@@ -5,12 +5,14 @@
<?php
<?php
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
use
yii\widgets\ActiveForm
;
use
yii\bootstrap\Modal
;
use
yii\helpers\Url
;
?>
?>
<div
class=
"customer-form"
>
<div
class=
"customer-form"
>
<?php
$form
=
ActiveForm
::
begin
([
'options'
=>
[
'enctype'
=>
'multipart/form-data'
],
'id'
=>
'dynamic-form'
]);
?>
<?php
$form
=
ActiveForm
::
begin
([
'options'
=>
[
'enctype'
=>
'multipart/form-data'
],
'id'
=>
'dynamic-form'
]);
?>
<div
class=
"panel panel-default"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
...
@@ -26,15 +28,50 @@ use yii\widgets\ActiveForm;
...
@@ -26,15 +28,50 @@ use yii\widgets\ActiveForm;
<td>
<?=
$value
[
'name'
]
?>
</td>
<td>
<?=
$value
[
'name'
]
?>
</td>
<?php
<?php
$theme_code
=
$model
->
code
;
$themeCode
=
$model
->
code
;
$file_code
=
$value
[
'code'
];
$fileCode
=
$value
[
'code'
];
if
(
$a
=
$modelFiles
[
0
]
::
isFileExist
(
$theme_code
,
$file_code
))
{
?>
$modelFiles
[
0
]
->
theme_code
=
$themeCode
;
$modelFiles
[
0
]
->
file_code
=
$fileCode
;
if
(
$modelFiles
[
0
]
::
isFileExist
(
$themeCode
,
$fileCode
))
{
?>
<td>
<?=
'edit'
?>
</td>
<td>
<?=
'edit'
?>
</td>
<?php
}
else
{
?>
<?php
}
else
{
?>
<td>
<?=
$form
->
field
(
$model
,
'theme_file'
)
->
fileInput
()
?>
</td>
<td>
<?=
Html
::
button
(
'Upload File'
,
[
'class'
=>
'btn btn-default'
,
'id'
=>
'modalButton'
.
$value
[
'id'
],
'onclick'
=>
'uploadJquery.upload('
.
$value
[
'id'
]
.
');'
])
?>
<?php
Modal
::
begin
([
'header'
=>
'<h3>Upload</h3>'
,
'id'
=>
'modal'
.
$value
[
'id'
],
'size'
=>
'modal-sm'
,
//keeps from closing modal with esc key or by clicking out of the modal.
// user must click cancel or X to close
]);
?>
<div
id=
'modalContent'
.
<?=
$value
[
'id'
]
?>
style=
"align-content: center"
>
<?=
$this
->
render
(
'upload'
,
[
'model'
=>
$model
,
'modelFiles'
=>
$modelFiles
,
])
?>
</div>
<?php
yii\bootstrap\Modal
::
end
();
?>
</td>
<?php
}
?>
<?php
}
?>
...
...
backend/modules/theme/views/theme-file/index.php
0 → 100644
View file @
c1b3cfd2
<?php
/* @var $this yii\web\View */
?>
<h1>
theme-file/index
</h1>
<p>
You may change the content of this page by modifying
the file
<code>
<?=
__FILE__
;
?>
</code>
.
</p>
backend/modules/theme/views/theme-file/upload.php
0 → 100644
View file @
c1b3cfd2
<?php
/**
* Created by PhpStorm.
* User: Junaid Rahman
* Date: 21-09-2016
* Time: 01:15 PM
*/
/* @var $modelFiles common\models\ThemeFiles */
use
yii\widgets\ActiveForm
;
use
yii\bootstrap\Html
;
?>
<?php
$form
=
ActiveForm
::
begin
();
?>
<div
id=
"myTabContent"
class=
"tab-content"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<p>
Choose your file to upload
</p>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$modelFiles
[
0
],
'file'
)
->
fileInput
([
'class'
=>
'btn btn-primary'
])
?>
<?=
$modelFiles
[
0
]
->
file_code
?>
</div>
</div>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
()
?>
</div>
<?php
ActiveForm
::
end
();
?>
\ No newline at end of file
backend/modules/theme/views/theme/file.php
View file @
c1b3cfd2
...
@@ -12,7 +12,7 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -12,7 +12,7 @@ $this->params['breadcrumbs'][] = $this->title;
<div
class=
"theme-create"
>
<div
class=
"theme-create"
>
<?=
$this
->
render
(
'..\theme
_
file\_form'
,
[
<?=
$this
->
render
(
'..\theme
-
file\_form'
,
[
'model'
=>
$model
,
'model'
=>
$model
,
'modelFiles'
=>
$modelFiles
,
'modelFiles'
=>
$modelFiles
,
'categoryFiles'
=>
$categoryFiles
,
'categoryFiles'
=>
$categoryFiles
,
...
...
backend/modules/theme/views/theme_file/index.php
deleted
100644 → 0
View file @
010258b8
<?php
use
yii\helpers\Html
;
use
yii\grid\GridView
;
use
common\grid\EnumColumn
;
use
common\models\Theme
;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\theme\models\search\ThemeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this
->
title
=
Yii
::
t
(
'backend'
,
'Themes'
);
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<div
class=
"theme-index"
>
<?php
// echo $this->render('_search', ['model' => $searchModel]); ?>
<
p
>
<?=
Html
::
a
(
Yii
::
t
(
'backend'
,
'Create {modelClass}'
,
[
'modelClass'
=>
'ThemeFiles'
,
]),
[
'create'
],
[
'class'
=>
'btn btn-success'
])
?>
</p>
<?=
GridView
::
widget
([
'dataProvider'
=>
$dataProvider
,
'filterModel'
=>
$searchModel
,
'columns'
=>
[
[
'class'
=>
'yii\grid\SerialColumn'
],
'id'
,
'theme_code'
,
'file_code'
,
'base_url'
,
'base_path'
,
// 'description',
// [
// 'class' => EnumColumn::className(),
// 'attribute' => 'status',
// 'enum' => Theme::statuses(),
// 'filter' => Theme::statuses()
// ],
// 'status',
// 'created_at',
// 'updated_at',
// ['class' => 'yii\grid\ActionColumn'
// ],
// ['class' => 'yii\grid\ActionColumn',
// 'template' => '{update}{delete}'],
],
]);
?>
</div>
backend/web/js/main.js
0 → 100644
View file @
c1b3cfd2
/**
* Created by Junaid Rahman on 21-09-2016.
*/
uploadJquery
=
{
upload
:
function
(
id
)
{
$
(
'#modalButton'
+
id
).
click
(
function
()
{
$
(
'#modal'
+
id
).
modal
(
'show'
)
.
find
(
'#modalContent'
+
id
)
.
load
(
$
(
this
).
attr
[
'value'
]);
});
}
};
common/migrations/db/m160903_101233_theme.php
View file @
c1b3cfd2
...
@@ -28,8 +28,6 @@ class m160903_101233_theme extends Migration
...
@@ -28,8 +28,6 @@ class m160903_101233_theme extends Migration
'id'
=>
$this
->
primaryKey
(),
'id'
=>
$this
->
primaryKey
(),
'theme_code'
=>
$this
->
integer
()
->
notNull
(),
'theme_code'
=>
$this
->
integer
()
->
notNull
(),
'file_code'
=>
$this
->
integer
()
->
notNull
(),
'file_code'
=>
$this
->
integer
()
->
notNull
(),
'base_url'
=>
$this
->
string
(
1024
),
'base_path'
=>
$this
->
string
(
1024
),
'created_at'
=>
$this
->
integer
(),
'created_at'
=>
$this
->
integer
(),
'updated_at'
=>
$this
->
integer
()
'updated_at'
=>
$this
->
integer
()
],
$tableOptions
);
],
$tableOptions
);
...
...
common/models/Theme.php
View file @
c1b3cfd2
...
@@ -25,15 +25,6 @@ class Theme extends \yii\db\ActiveRecord
...
@@ -25,15 +25,6 @@ class Theme extends \yii\db\ActiveRecord
{
{
const
STATUS_ACTIVE
=
1
;
const
STATUS_ACTIVE
=
1
;
const
STATUS_IN_ACTIVE
=
0
;
const
STATUS_IN_ACTIVE
=
0
;
/*
* @upload file
*/
public
$theme_file
;
/*
* @upload file
*/
public
$file
;
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
@@ -53,8 +44,6 @@ class Theme extends \yii\db\ActiveRecord
...
@@ -53,8 +44,6 @@ class Theme extends \yii\db\ActiveRecord
[[
'code'
,
'slug'
,
'name'
],
'string'
,
'max'
=>
32
],
[[
'code'
,
'slug'
,
'name'
],
'string'
,
'max'
=>
32
],
[[
'description'
],
'string'
,
'max'
=>
512
],
[[
'description'
],
'string'
,
'max'
=>
512
],
[[
'category_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
Category
::
className
(),
'targetAttribute'
=>
[
'category_id'
=>
'id'
]],
[[
'category_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
Category
::
className
(),
'targetAttribute'
=>
[
'category_id'
=>
'id'
]],
[[
'theme_file'
],
'safe'
],
[[
'theme_file'
],
'file'
,
'extensions'
=>
'js, css, html'
],
];
];
}
}
...
...
common/models/ThemeFiles.php
View file @
c1b3cfd2
...
@@ -21,7 +21,10 @@ use Yii;
...
@@ -21,7 +21,10 @@ use Yii;
*/
*/
class
ThemeFiles
extends
\yii\db\ActiveRecord
class
ThemeFiles
extends
\yii\db\ActiveRecord
{
{
/*
* @var file upload
*/
public
$file
;
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
@@ -41,6 +44,7 @@ class ThemeFiles extends \yii\db\ActiveRecord
...
@@ -41,6 +44,7 @@ class ThemeFiles extends \yii\db\ActiveRecord
[[
'base_url'
,
'base_path'
],
'string'
,
'max'
=>
1024
],
[[
'base_url'
,
'base_path'
],
'string'
,
'max'
=>
1024
],
[[
'file_code'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
CategoryFiles
::
className
(),
'targetAttribute'
=>
[
'file_code'
=>
'id'
]],
[[
'file_code'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
CategoryFiles
::
className
(),
'targetAttribute'
=>
[
'file_code'
=>
'id'
]],
[[
'theme_code'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
Theme
::
className
(),
'targetAttribute'
=>
[
'theme_code'
=>
'id'
]],
[[
'theme_code'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
Theme
::
className
(),
'targetAttribute'
=>
[
'theme_code'
=>
'id'
]],
[[
'file'
],
'file'
],
];
];
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment