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
37ea8297
Commit
37ea8297
authored
Sep 24, 2016
by
Junaid Rahman pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixing
parent
5975a46b
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
174 additions
and
68 deletions
+174
-68
DistrictController.php
backend/modules/location/controllers/DistrictController.php
+10
-0
StateController.php
backend/modules/location/controllers/StateController.php
+10
-0
CategoryController.php
backend/modules/theme/controllers/CategoryController.php
+13
-14
ThemeController.php
backend/modules/theme/controllers/ThemeController.php
+19
-1
ThemeFileController.php
backend/modules/theme/controllers/ThemeFileController.php
+73
-19
index.php
backend/modules/theme/views/category/index.php
+7
-12
_form.php
backend/modules/theme/views/file/_form.php
+1
-2
_form.php
backend/modules/theme/views/theme-file/_form.php
+5
-1
upload.php
backend/modules/theme/views/theme-file/upload.php
+7
-4
_form.php
backend/modules/theme/views/theme/_form.php
+1
-1
index.php
backend/modules/theme/views/theme/index.php
+13
-6
common.php
backend/views/layouts/common.php
+4
-3
m160830_105840_category.php
common/migrations/db/m160830_105840_category.php
+3
-3
Category.php
common/models/Category.php
+1
-0
CategoryFiles.php
common/models/CategoryFiles.php
+1
-0
ThemeFiles.php
common/models/ThemeFiles.php
+6
-2
No files found.
backend/modules/location/controllers/DistrictController.php
View file @
37ea8297
...
...
@@ -70,6 +70,16 @@ class DistrictController extends Controller
$states
=
ArrayHelper
::
map
(
State
::
find
()
->
all
(),
'id'
,
'name'
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'districtCreate'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-map'
,
'message'
=>
' New District added'
,
'showSeparator'
=>
true
,
'title'
=>
' District'
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
return
$this
->
render
(
'create'
,
[
...
...
backend/modules/location/controllers/StateController.php
View file @
37ea8297
...
...
@@ -66,6 +66,16 @@ class StateController extends Controller
$model
=
new
State
();
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'stateCreate'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-map'
,
'message'
=>
' New State added'
,
'showSeparator'
=>
true
,
'title'
=>
' State'
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
return
$this
->
render
(
'create'
,
[
...
...
backend/modules/theme/controllers/CategoryController.php
View file @
37ea8297
...
...
@@ -72,11 +72,11 @@ class CategoryController extends Controller
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-
envira
'
,
'message'
=>
'New
Theme Category
Created! '
,
'icon'
=>
'fa fa-
sitemap
'
,
'message'
=>
'New
Category '
.
$model
->
name
.
' is
Created! '
,
'title'
=>
'Category'
,
'positonY'
=>
'top'
,
'positonX'
=>
'
right
'
'positonX'
=>
'
center
'
]);
return
$this
->
redirect
([
'files'
,
'id'
=>
$model
->
id
]);
}
...
...
@@ -99,7 +99,16 @@ class CategoryController extends Controller
$model
=
$this
->
findModel
(
$id
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
()
&&
$model
->
validate
())
{
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-sitemap'
,
'message'
=>
'Category '
.
$model
->
name
.
' Updated! '
,
'title'
=>
'Category'
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
return
$this
->
redirect
([
'files'
,
'id'
=>
$model
->
id
]);
}
return
$this
->
render
(
'update'
,
[
...
...
@@ -139,7 +148,6 @@ class CategoryController extends Controller
if
(
Model
::
loadMultiple
(
$models
,
Yii
::
$app
->
request
->
post
()))
{
$deletedIDs
=
array_diff
(
$oldIDs
,
array_filter
(
ArrayHelper
::
map
(
$models
,
'id'
,
'id'
)));
if
(
Model
::
validateMultiple
(
$models
))
{
$transaction
=
\Yii
::
$app
->
db
->
beginTransaction
();
...
...
@@ -159,15 +167,6 @@ class CategoryController extends Controller
if
(
$flag
)
{
$transaction
->
commit
();
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-file'
,
'message'
=>
'New File is added to Category Files list! '
,
'title'
=>
'Category Files'
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
}
}
catch
(
Exception
$e
)
{
$transaction
->
rollBack
();
...
...
backend/modules/theme/controllers/ThemeController.php
View file @
37ea8297
...
...
@@ -73,7 +73,16 @@ class ThemeController extends Controller
$model
=
new
Theme
();
$model
->
status
=
$model
::
STATUS_ACTIVE
;
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-envira'
,
'message'
=>
'New Theme '
.
$model
->
name
.
' is Created! '
,
'title'
=>
' Theme'
,
'positonY'
=>
'top'
,
'positonX'
=>
'center'
]);
return
$this
->
redirect
([
'files'
,
'id'
=>
$model
->
id
]);
}
return
$this
->
render
(
'create'
,
[
'model'
=>
$model
,
...
...
@@ -94,6 +103,15 @@ class ThemeController extends Controller
$model
=
$this
->
findModel
(
$id
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-envira'
,
'message'
=>
'Theme '
.
$model
->
name
.
' Updated! '
,
'title'
=>
'Theme'
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
return
$this
->
render
(
'update'
,
[
...
...
backend/modules/theme/controllers/ThemeFileController.php
View file @
37ea8297
...
...
@@ -4,7 +4,6 @@ namespace backend\modules\theme\controllers;
use
common\models\ThemeFiles
;
use
yii
;
use
common\models\Theme
;
use
yii\web\NotFoundHttpException
;
use
yii\web\UploadedFile
;
...
...
@@ -14,6 +13,7 @@ class ThemeFileController extends \yii\web\Controller
{
return
$this
->
render
(
'index'
);
}
public
function
actionUpload
()
{
$model
=
new
ThemeFiles
();
...
...
@@ -24,37 +24,91 @@ class ThemeFileController extends \yii\web\Controller
// the following data will return an array
$theme_file
=
UploadedFile
::
getInstance
(
$model
,
'file'
);
// the path to save file,
$folderPath
=
yii
::
getAlias
(
'@storage/private/theme-assets/'
)
.
$model
->
theme_code
;
if
(
!
is_dir
(
$folderPath
))
{
mkdir
(
$folderPath
);
}
$path
=
$folderPath
.
'/'
.
$model
->
file_code
;
if
(
$model
->
save
(
false
))
{
$theme_file
->
saveAs
(
$path
);
$model
->
file
=
$theme_file
;
$ext
=
$model
->
file
->
extension
;
$allowed
=
array
(
'js'
,
'css'
,
'html'
);
if
(
in_array
(
$ext
,
$allowed
))
{
// the path to save file,
$folderPath
=
yii
::
getAlias
(
'@storage/private/theme-assets/'
)
.
$model
->
theme_code
;
if
(
!
is_dir
(
$folderPath
))
{
mkdir
(
$folderPath
);
}
$path
=
$folderPath
.
'/'
.
$model
->
file_code
;
if
(
$model
->
save
(
false
))
{
$model
->
file
->
saveAs
(
$path
);
Yii
::
$app
->
getSession
()
->
setFlash
(
$model
->
file_code
,
[
'type'
=>
'warning'
,
'duration'
=>
4000
,
'icon'
=>
'fa fa-file'
,
'message'
=>
''
.
$model
->
file_code
.
' Uploading...'
,
'showSeparator'
=>
true
,
'title'
=>
' File Upload'
,
'showProgressbar'
=>
true
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-file'
,
'message'
=>
' File successfully Uploaded'
,
'showSeparator'
=>
true
,
'title'
=>
' File Upload'
,
'delay'
=>
4000
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
}
else
{
echo
'Error'
;
exit
();
}
}
else
{
echo
'Error'
;
exit
();
Yii
::
$app
->
getSession
()
->
setFlash
(
'alert'
,
[
'type'
=>
'danger'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-envira'
,
'message'
=>
'File type miss match! '
,
'showSeparator'
=>
true
,
'title'
=>
'Error'
,
'showProgressbar'
=>
true
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
}
}
return
$this
->
redirect
([
'theme/
index'
]);
return
$this
->
redirect
([
'theme/
files'
,
'id'
=>
$model
->
theme_id
]);
}
public
function
actionEditor
(
$id
)
{
public
function
actionEditor
(
$id
)
{
$model
=
$this
->
findModel
(
$id
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
$file
=
yii
::
getAlias
(
'@storage/private/theme-assets/'
)
.
$model
->
theme_code
.
'/'
.
$model
->
file_code
;
$file
=
yii
::
getAlias
(
'@storage/private/theme-assets/'
)
.
$model
->
theme_code
.
'/'
.
$model
->
file_code
;
file_put_contents
(
$file
,
$model
->
fileContent
);
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
[
'type'
=>
'success'
,
'duration'
=>
5000
,
'icon'
=>
'fa fa-file'
,
'message'
=>
' File Saved'
,
'showSeparator'
=>
true
,
'title'
=>
' Code Editor'
,
'positonY'
=>
'top'
,
'positonX'
=>
'right'
]);
}
return
$this
->
render
(
'editor'
,[
'model'
=>
$model
,
return
$this
->
render
(
'editor'
,
[
'model'
=>
$model
,
]);
}
protected
function
findModel
(
$id
)
{
protected
function
findModel
(
$id
)
{
if
((
$model
=
ThemeFiles
::
findOne
(
$id
))
!==
null
)
{
return
$model
;
}
else
{
...
...
backend/modules/theme/views/category/index.php
View file @
37ea8297
...
...
@@ -45,19 +45,14 @@ $this->params['breadcrumbs'][] = $this->title;
[
'class'
=>
'yii\grid\ActionColumn'
,
'template'
=>
'{update} {delete}'
,
'template'
=>
'{update} {
files} {
delete}'
,
'buttons'
=>
[
'download'
=>
function
(
$url
)
{
return
Html
::
a
(
'<span class="glyphicon glyphicon-arrow-download"></span>'
,
$url
,
[
'title'
=>
'Download'
,
'data-pjax'
=>
'0'
,
]
);
},
],
'files'
=>
function
(
$url
)
{
return
Html
::
a
(
'<span class="fa fa-file"></span>'
,
$url
,
[
'title'
=>
Yii
::
t
(
'yii'
,
'Files'
),
]);
}
]
],
],
]);
?>
...
...
backend/modules/theme/views/file/_form.php
View file @
37ea8297
...
...
@@ -75,8 +75,7 @@ use wbraganca\dynamicform\DynamicFormWidget;
</div>
<div
class=
"col-sm-4"
>
<?=
$form
->
field
(
$model
,
"[
{
$i
}
]type"
)
->
dropDownList
(
$model
::
getfiles
(),
[
'prompt'
=>
''
])
?>
<?=
$form
->
field
(
$model
,
"[
{
$i
}
]type"
)
->
dropDownList
(
$model
::
getfiles
())
?>
</div>
</div>
...
...
backend/modules/theme/views/theme-file/_form.php
View file @
37ea8297
...
...
@@ -65,7 +65,11 @@ use yii\bootstrap\Modal;
<div
id=
'modalContent'
<?=
$value
[
'id'
]
?>
style=
"text-align: center"
>
<?=
$this
->
render
(
'upload'
,
[
'model'
=>
$modelFiles
[
0
],])
?>
<?=
$this
->
render
(
'upload'
,
[
'model'
=>
$modelFiles
[
0
],
'ThemeId'
=>
$model
->
id
,
])
?>
</div>
...
...
backend/modules/theme/views/theme-file/upload.php
View file @
37ea8297
...
...
@@ -7,6 +7,7 @@
*/
/* @var $model common\models\ThemeFiles */
/* @var $ThemeId id of theme */
use
yii\widgets\ActiveForm
;
use
yii\bootstrap\Html
;
...
...
@@ -25,19 +26,21 @@ use yii\bootstrap\Html;
<div
class=
"col-md-11"
>
<?=
$form
->
field
(
$model
,
'file'
)
->
fileInput
([
'class'
=>
'btn btn-default'
])
?>
</div>
<div
class=
"col-md-11"
>
<?=
$form
->
field
(
$model
,
'file_code'
)
->
hiddenInput
([
'value'
=>
$model
->
file_code
])
->
label
(
false
)
?>
</div>
<div
class=
"col-md-11"
>
<?=
$form
->
field
(
$model
,
'theme_code'
)
->
hiddenInput
([
'value'
=>
$model
->
theme_code
])
->
label
(
false
)
?>
</div>
<div
class=
"col-md-11"
>
<?=
$form
->
field
(
$model
,
'theme_id'
)
->
hiddenInput
([
'value'
=>
$ThemeId
])
->
label
(
false
)
?>
</div>
</div>
...
...
backend/modules/theme/views/theme/_form.php
View file @
37ea8297
...
...
@@ -57,7 +57,7 @@ use yii\bootstrap\ActiveForm;
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'status'
)
->
dropDownList
(
$model
::
statuses
()
,
[
'prompt'
=>
''
]
)
?>
<?=
$form
->
field
(
$model
,
'status'
)
->
dropDownList
(
$model
::
statuses
())
?>
</div>
</div>
...
...
backend/modules/theme/views/theme/index.php
View file @
37ea8297
...
...
@@ -18,8 +18,8 @@ $this->params['breadcrumbs'][] = $this->title;
<
p
>
<?=
Html
::
a
(
Yii
::
t
(
'backend'
,
'Create {modelClass}'
,
[
'modelClass'
=>
'Theme'
,
]),
[
'create'
],
[
'class'
=>
'btn btn-success'
])
?>
'modelClass'
=>
'Theme'
,
]),
[
'create'
],
[
'class'
=>
'btn btn-success'
])
?>
</p>
<?=
GridView
::
widget
([
...
...
@@ -44,11 +44,18 @@ $this->params['breadcrumbs'][] = $this->title;
// 'created_at',
// 'updated_at',
[
'class'
=>
'yii\grid\ActionColumn'
[
'class'
=>
'yii\grid\ActionColumn'
,
'template'
=>
'{update} {files} {delete}'
,
'buttons'
=>
[
'files'
=>
function
(
$url
)
{
return
Html
::
a
(
'<span class="fa fa-file"></span>'
,
$url
,
[
'title'
=>
Yii
::
t
(
'yii'
,
'Files'
),
]);
}
]
],
// ['class' => 'yii\grid\ActionColumn',
// 'template' => '{update}{delete}'],
],
]);
?>
...
...
backend/views/layouts/common.php
View file @
37ea8297
...
...
@@ -342,12 +342,13 @@ $bundle = BackendAsset::register($this);
<?php
foreach
(
Yii
::
$app
->
session
->
getAllFlashes
()
as
$message
)
:
;
?>
<?=
Growl
::
widget
([
'type'
=>
(
!
empty
(
$message
[
'type'
]))
?
$message
[
'type'
]
:
'danger'
,
'title'
=>
(
!
empty
(
$message
[
'title'
]))
?
Html
::
encode
(
$message
[
'title'
])
:
'
Title Not Set
!'
,
'title'
=>
(
!
empty
(
$message
[
'title'
]))
?
Html
::
encode
(
$message
[
'title'
])
:
'
Libromi Web
!'
,
'icon'
=>
(
!
empty
(
$message
[
'icon'
]))
?
$message
[
'icon'
]
:
'fa fa-info'
,
'body'
=>
(
!
empty
(
$message
[
'message'
]))
?
Html
::
encode
(
$message
[
'message'
])
:
'
Message Not Set
!'
,
'body'
=>
(
!
empty
(
$message
[
'message'
]))
?
Html
::
encode
(
$message
[
'message'
])
:
'
Welcome to Libromi Web
!'
,
'showSeparator'
=>
true
,
'delay'
=>
1
,
//This delay is how long before the message shows
'delay'
=>
(
!
empty
(
$message
[
'delay'
]))
?
Html
::
encode
(
$message
[
'delay'
])
:
1
,
//This delay is how long before the message shows
'pluginOptions'
=>
[
'showProgressbar'
=>
(
!
empty
(
$message
[
'showProgressbar'
]))
?
Html
::
encode
(
$message
[
'showProgressbar'
])
:
false
,
'delay'
=>
(
!
empty
(
$message
[
'duration'
]))
?
$message
[
'duration'
]
:
3000
,
//This delay is how long the message shows for
'placement'
=>
[
'from'
=>
(
!
empty
(
$message
[
'positonY'
]))
?
$message
[
'positonY'
]
:
'top'
,
...
...
common/migrations/db/m160830_105840_category.php
View file @
37ea8297
...
...
@@ -40,13 +40,13 @@ class m160830_105840_category extends Migration
$this
->
createIndex
(
'idx_category_files_code'
,
'{{%category_files}}'
,
'code'
);
$this
->
createIndex
(
'idx_category_files_name'
,
'{{%category_files}}'
,
'name'
);
$this
->
addForeignKey
(
'fk_category
'
,
'{{%category_files}}'
,
'category_id'
,
'{{%category}}'
,
'id'
,
'RESTRICT
'
,
'
RESTRICT
'
);
$this
->
addForeignKey
(
'fk_category
_files_category'
,
'{{%category_files}}'
,
'category_id'
,
'{{%category}}'
,
'id'
,
'cascade
'
,
'
cascade
'
);
}
public
function
safeDown
()
{
$this
->
dropForeignKey
(
'fk_category'
,
'{{%category_files}}'
);
$this
->
dropForeignKey
(
'fk_category
_files_category
'
,
'{{%category_files}}'
);
$this
->
dropIndex
(
'idx_category_files_name'
,
'{{%category_files}}'
);
$this
->
dropIndex
(
'idx_category_files_code'
,
'{{%category_files}}'
);
...
...
common/models/Category.php
View file @
37ea8297
...
...
@@ -137,4 +137,5 @@ class Category extends \yii\db\ActiveRecord
];
}
}
common/models/CategoryFiles.php
View file @
37ea8297
...
...
@@ -93,4 +93,5 @@ class CategoryFiles extends \yii\db\ActiveRecord
self
::
TYPE_HTML_BLOCK
=>
Yii
::
t
(
'common'
,
'HTML BLOCK'
),
];
}
}
common/models/ThemeFiles.php
View file @
37ea8297
...
...
@@ -27,6 +27,10 @@ class ThemeFiles extends \yii\db\ActiveRecord
*/
public
$file
;
/*
* @var theme_id using to render file page
*/
public
$theme_id
;
/*
* @var file upload
*/
public
$fileContent
;
...
...
@@ -56,10 +60,10 @@ class ThemeFiles extends \yii\db\ActiveRecord
return
[
[[
'theme_code'
,
'file_code'
,
'file'
],
'required'
],
[[
'theme_code'
,
'file_code'
,
'fileContent'
],
'string'
],
[[
'created_at'
,
'updated_at'
],
'integer'
],
[[
'created_at'
,
'updated_at'
,
'theme_id'
],
'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'
]],
[[
'file'
],
'file'
],
[[
'file'
],
'file'
,
'skipOnEmpty'
=>
false
,
'extensions'
=>
'js,css,html'
],
];
}
...
...
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