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
05f96e6f
Commit
05f96e6f
authored
Sep 08, 2016
by
dianc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Theme Menu Generation
parent
e410c978
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
18 deletions
+136
-18
ThemeController.php
backend/modules/theme/controllers/ThemeController.php
+10
-3
_form.php
backend/modules/theme/views/category/_form.php
+6
-0
_form.php
backend/modules/theme/views/file/_form.php
+0
-3
_form.php
backend/modules/theme/views/theme/_form.php
+19
-8
file.php
backend/modules/theme/views/theme/file.php
+19
-0
layout.php
backend/modules/theme/views/theme/layout.php
+40
-0
Category.php
common/models/Category.php
+12
-0
Theme.php
common/models/Theme.php
+19
-1
CategoryQuery.php
common/models/query/CategoryQuery.php
+11
-3
No files found.
backend/modules/theme/controllers/ThemeController.php
View file @
05f96e6f
...
...
@@ -5,6 +5,7 @@ namespace backend\modules\theme\controllers;
use
Yii
;
use
common\models\Theme
;
use
backend\modules\theme\models\search\ThemeSearch
;
use
yii\helpers\Html
;
use
yii\web\Controller
;
use
yii\web\NotFoundHttpException
;
use
yii\filters\VerbFilter
;
...
...
@@ -32,6 +33,8 @@ class ThemeController extends Controller
*/
public
function
actionIndex
()
{
$searchModel
=
new
ThemeSearch
();
$dataProvider
=
$searchModel
->
search
(
Yii
::
$app
->
request
->
queryParams
);
...
...
@@ -60,15 +63,17 @@ class ThemeController extends Controller
*/
public
function
actionCreate
()
{
$
model
=
new
Theme
()
;
$
this
->
layout
=
'@backend/modules/theme/views/theme/layout.php'
;
$model
=
new
Theme
();
$model
->
status
=
$model
::
STATUS_ACTIVE
;
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
}
return
$this
->
render
(
'create'
,
[
'model'
=>
$model
,
]);
}
}
/**
...
...
@@ -79,6 +84,8 @@ class ThemeController extends Controller
*/
public
function
actionUpdate
(
$id
)
{
$this
->
layout
=
'@backend/modules/theme/views/theme/layout.php'
;
$model
=
$this
->
findModel
(
$id
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
...
...
backend/modules/theme/views/category/_form.php
View file @
05f96e6f
...
...
@@ -16,7 +16,9 @@ use trntv\filekit\widget\Upload;
<div
id=
"myTabContent"
class=
"tab-content"
>
<div
class=
"tab-pane fade in active"
id=
"info"
>
<div
class=
"page-header"
>
<h3>
<?=
Yii
::
t
(
'backend'
,
'Info'
)
?>
</h3>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
...
...
@@ -41,12 +43,14 @@ use trntv\filekit\widget\Upload;
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'image'
)
->
widget
(
Upload
::
className
(),
[
'url'
=>
[
'/file-storage/upload'
],
])
->
label
(
'Image'
);
?>
</div>
</div>
<div
class=
"row"
>
...
...
@@ -55,8 +59,10 @@ use trntv\filekit\widget\Upload;
</div>
</div>
<div
class=
"form-group"
>
<?php
echo
Html
::
submitButton
(
$model
->
isNewRecord
?
Yii
::
t
(
'backend'
,
'Create'
)
:
Yii
::
t
(
'backend'
,
'Update'
),
[
'class'
=>
$model
->
isNewRecord
?
'btn btn-success'
:
'btn btn-primary'
])
?>
</div>
</div>
<div
class=
"tab-pane fade in"
id=
"files"
>
...
...
backend/modules/theme/views/file/_form.php
View file @
05f96e6f
...
...
@@ -12,9 +12,6 @@ use wbraganca\dynamicform\DynamicFormWidget;
<?php
$form
=
ActiveForm
::
begin
([
'id'
=>
'dynamic-form'
]);
?>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4><i
class=
"glyphicon glyphicon-envelope"
></i>
Addresses
</h4>
</div>
<div
class=
"panel-body"
>
<?php
DynamicFormWidget
::
begin
([
'widgetContainer'
=>
'dynamicform_wrapper'
,
// required: only alphanumeric characters plus "_" [A-Za-z0-9_]
...
...
backend/modules/theme/views/theme/_form.php
View file @
05f96e6f
...
...
@@ -11,49 +11,60 @@ use yii\bootstrap\ActiveForm;
<div
class=
"theme-form"
>
<?php
$form
=
ActiveForm
::
begin
();
?>
<div
id=
"myTabContent"
class=
"tab-content"
>
<div
class=
"tab-pane fade in active"
id=
"info"
>
<div
class=
"page-header"
>
<h3>
<?=
Yii
::
t
(
'backend'
,
'Info'
)
?>
</h3>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'category_id'
)
->
textInput
()
?>
<?=
$form
->
field
(
$model
,
'category_id'
)
->
dropDownList
(
\common\models\Category
::
getAllCategories
(),
[
'prompt'
=>
''
])
?>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'code'
)
->
textInput
([
'maxlength'
=>
true
])
?>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'slug'
)
->
textInput
([
'maxlength'
=>
true
])
?>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'name'
)
->
textInput
([
'maxlength'
=>
true
])
?>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'description'
)
->
textInput
([
'maxlength'
=>
true
])
?>
<?=
$form
->
field
(
$model
,
'description'
)
->
textarea
([
'maxlength'
=>
true
])
?>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?=
$form
->
field
(
$model
,
'status'
)
->
dropDownList
(
$model
::
statuses
(),
[
'prompt'
=>
''
])
?>
</div>
</div>
<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>
<div
class=
"tab-pane fade in"
id=
"files"
>
<div
class=
"page-header"
>
<h3>
Files
</h3>
</div>
</div>
<?php
ActiveForm
::
end
();
?>
...
...
backend/modules/theme/views/theme/file.php
0 → 100644
View file @
05f96e6f
<?php
/* @var $this yii\web\View */
/* @var $model common\models\Theme */
/* @var $modelFiles common\models\ThemeFiles */
$this
->
params
[
'themeId'
]
=
false
;
$this
->
title
=
'Create Theme File'
;
$this
->
params
[
'breadcrumbs'
][]
=
[
'label'
=>
Yii
::
t
(
'backend'
,
'Theme'
),
'url'
=>
[
'index'
]];
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<div
class=
"theme-create"
>
<?=
$this
->
render
(
'..\file\_form'
,
[
'model'
=>
$model
,
'modelFiles'
=>
$modelFiles
,
])
?>
</div>
backend/modules/theme/views/theme/layout.php
0 → 100644
View file @
05f96e6f
<?php
use
yii\widgets\Menu
;
/* @var $this yii\web\View */
?>
<?php
$this
->
beginContent
(
'@backend/views/layouts/main.php'
);
?>
<?=
Menu
::
widget
([
'items'
=>
[
[
'label'
=>
'Info'
,
'url'
=>
$this
->
params
[
'themeId'
]
?
[
'theme/update'
,
'id'
=>
$this
->
params
[
'themeId'
]]
:
[
'theme/create'
],
],
[
'label'
=>
'Files'
,
'url'
=>
$this
->
params
[
'themeId'
]
?
[
'theme/files'
,
'id'
=>
$this
->
params
[
'themeId'
]]
:
'#'
,
'options'
=>
[
'class'
=>
$this
->
params
[
'themeId'
]
?
''
:
'disabled'
]
],
],
'options'
=>
[
'class'
=>
'nav nav-tabs'
,
'role'
=>
'tablist'
,
'id'
=>
'theme-form-tab'
,
],
]);
?>
<div
class=
"tab-content"
>
<?=
$content
?>
</div>
<?php
$this
->
endContent
();
?>
common/models/Category.php
View file @
05f96e6f
...
...
@@ -7,6 +7,7 @@ use common\models\query\CategoryQuery;
use
yii\behaviors\SluggableBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
trntv\filekit\behaviors\UploadBehavior
;
use
yii\helpers\ArrayHelper
;
/**
* This is the model class for table "{{%category}}".
...
...
@@ -92,6 +93,16 @@ class Category extends \yii\db\ActiveRecord
];
}
public
static
function
getAllCategories
()
{
$models
=
static
::
find
()
->
active
()
->
all
();
return
ArrayHelper
::
map
(
$models
,
'id'
,
'name'
);
}
/**
* @return \yii\db\ActiveQuery
*/
...
...
@@ -116,4 +127,5 @@ class Category extends \yii\db\ActiveRecord
self
::
STATUS_IN_ACTIVE
=>
Yii
::
t
(
'common'
,
'In Active'
),
];
}
}
common/models/Theme.php
View file @
05f96e6f
...
...
@@ -3,6 +3,8 @@
namespace
common\models
;
use
Yii
;
use
yii\behaviors\SluggableBehavior
;
use
yii\behaviors\TimestampBehavior
;
/**
* This is the model class for table "{{%theme}}".
...
...
@@ -38,7 +40,7 @@ class Theme extends \yii\db\ActiveRecord
public
function
rules
()
{
return
[
[[
'category_id'
,
'code'
,
'
slug'
,
'
name'
,
'status'
],
'required'
],
[[
'category_id'
,
'code'
,
'name'
,
'status'
],
'required'
],
[[
'category_id'
,
'status'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'code'
,
'slug'
,
'name'
],
'string'
,
'max'
=>
32
],
[[
'description'
],
'string'
,
'max'
=>
512
],
...
...
@@ -46,6 +48,22 @@ class Theme extends \yii\db\ActiveRecord
];
}
public
function
behaviors
()
{
return
[
[
'class'
=>
SluggableBehavior
::
className
(),
'attribute'
=>
'name'
,
],
[
'class'
=>
TimestampBehavior
::
className
(),
'createdAtAttribute'
=>
'created_at'
,
'updatedAtAttribute'
=>
'updated_at'
]
];
}
/**
* @inheritdoc
*/
...
...
common/models/query/CategoryQuery.php
View file @
05f96e6f
...
...
@@ -2,6 +2,8 @@
namespace
common\models\query
;
use
common\models\Category
;
use
yii\helpers\ArrayHelper
;
/**
* This is the ActiveQuery class for [[Category]].
*
...
...
@@ -9,10 +11,16 @@ namespace common\models\query;
*/
class
CategoryQuery
extends
\yii\db\ActiveQuery
{
/*public function active()
// public function active()
// {
// return $this->andWhere('[[status]]=1');
// }
public
function
active
()
{
return $this->andWhere('[[status]]=1');
}*/
$this
->
andWhere
([
'status'
=>
Category
::
STATUS_ACTIVE
]);
return
$this
;
}
/**
* @inheritdoc
...
...
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