Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
ecfaca54
Commit
ecfaca54
authored
Feb 19, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Для категорий сделать страницу “Справочник Категорий”
parent
9dca5a70
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
357 additions
and
39 deletions
+357
-39
common/modules/blog/Module.php
common/modules/blog/Module.php
+1
-0
common/modules/blog/components/TagBehavior.php
common/modules/blog/components/TagBehavior.php
+5
-3
common/modules/blog/controllers/TagAdminController.php
common/modules/blog/controllers/TagAdminController.php
+134
-0
common/modules/blog/models/PostTag.php
common/modules/blog/models/PostTag.php
+20
-0
common/modules/blog/models/SearchPostTag.php
common/modules/blog/models/SearchPostTag.php
+71
-0
common/modules/blog/views/post-admin/_form.php
common/modules/blog/views/post-admin/_form.php
+1
-1
common/modules/blog/views/post-admin/_search.php
common/modules/blog/views/post-admin/_search.php
+0
-35
common/modules/blog/views/tag-admin/_form.php
common/modules/blog/views/tag-admin/_form.php
+23
-0
common/modules/blog/views/tag-admin/create.php
common/modules/blog/views/tag-admin/create.php
+19
-0
common/modules/blog/views/tag-admin/manage.php
common/modules/blog/views/tag-admin/manage.php
+32
-0
common/modules/blog/views/tag-admin/update.php
common/modules/blog/views/tag-admin/update.php
+19
-0
common/modules/blog/views/tag-admin/view.php
common/modules/blog/views/tag-admin/view.php
+32
-0
No files found.
common/modules/blog/Module.php
View file @
ecfaca54
...
@@ -43,6 +43,7 @@ class Module extends \common\components\WebModule
...
@@ -43,6 +43,7 @@ class Module extends \common\components\WebModule
{
{
return
array
(
return
array
(
'Записи'
=>
'/blog/post-admin/manage'
,
'Записи'
=>
'/blog/post-admin/manage'
,
'Теги'
=>
'/blog/tag-admin/manage'
,
);
);
}
}
}
}
common/modules/blog/components/TagBehavior.php
View file @
ecfaca54
...
@@ -43,9 +43,11 @@ class TagBehavior extends Behavior
...
@@ -43,9 +43,11 @@ class TagBehavior extends Behavior
$tg
=
PostTag
::
find
()
->
where
([
'name'
=>
$tag
])
->
one
();
$tg
=
PostTag
::
find
()
->
where
([
'name'
=>
$tag
])
->
one
();
if
(
!
$tg
)
if
(
!
$tg
)
{
{
$tg
=
new
PostTag
;
// Убрана возможность создавать новые теги
$tg
->
name
=
$tag
;
return
false
;
$tg
->
save
();
// $tg = new PostTag;
// $tg->name = $tag;
// $tg->save();
}
}
$tgs
=
new
PostTagAssign
;
$tgs
=
new
PostTagAssign
;
...
...
common/modules/blog/controllers/TagAdminController.php
0 → 100644
View file @
ecfaca54
<?php
namespace
common\modules\blog\controllers
;
use
Yii
;
use
common\modules\blog\models\PostTag
;
use
common\modules\blog\models\SearchPostTag
;
use
common\components\AdminController
;
use
yii\web\NotFoundHttpException
;
use
yii\filters\VerbFilter
;
/**
* TagAdminController implements the CRUD actions for PostTag model.
*/
class
TagAdminController
extends
AdminController
{
public
static
function
actionsTitles
(){
return
[
'Manage'
=>
'Управление тегами'
,
'Create'
=>
'Добавление тега'
,
'Update'
=>
'Редактирование тега'
,
'Delete'
=>
'Удаление тега'
,
'View'
=>
'Просмотр тега'
,
];
}
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'verbs'
=>
[
'class'
=>
VerbFilter
::
className
(),
'actions'
=>
[
'delete'
=>
[
'POST'
],
],
],
];
}
/**
* Lists all PostTag models.
* @return mixed
*/
public
function
actionManage
()
{
$searchModel
=
new
SearchPostTag
();
$dataProvider
=
$searchModel
->
search
(
Yii
::
$app
->
request
->
queryParams
);
return
$this
->
render
(
'manage'
,
[
'searchModel'
=>
$searchModel
,
'dataProvider'
=>
$dataProvider
,
]);
}
/**
* Displays a single PostTag model.
* @param integer $id
* @return mixed
*/
public
function
actionView
(
$id
)
{
return
$this
->
render
(
'view'
,
[
'model'
=>
$this
->
findModel
(
$id
),
]);
}
/**
* Creates a new PostTag model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public
function
actionCreate
()
{
$model
=
new
PostTag
();
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
return
$this
->
render
(
'create'
,
[
'model'
=>
$model
,
]);
}
}
/**
* Updates an existing PostTag model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public
function
actionUpdate
(
$id
)
{
$model
=
$this
->
findModel
(
$id
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
save
())
{
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
else
{
return
$this
->
render
(
'update'
,
[
'model'
=>
$model
,
]);
}
}
/**
* Deletes an existing PostTag model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public
function
actionDelete
(
$id
)
{
$this
->
findModel
(
$id
)
->
delete
();
return
$this
->
redirect
([
'manage'
]);
}
/**
* Finds the PostTag model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return PostTag the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected
function
findModel
(
$id
)
{
if
((
$model
=
PostTag
::
findOne
(
$id
))
!==
null
)
{
return
$model
;
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
}
common/modules/blog/models/PostTag.php
View file @
ecfaca54
...
@@ -91,6 +91,26 @@ class PostTag extends \common\components\ActiveRecordModel
...
@@ -91,6 +91,26 @@ class PostTag extends \common\components\ActiveRecordModel
return
$this
->
hasMany
(
PostTagAssign
::
className
(),
[
'tag_id'
=>
'id'
]);
return
$this
->
hasMany
(
PostTagAssign
::
className
(),
[
'tag_id'
=>
'id'
]);
}
}
public
function
beforeDelete
()
{
if
(
parent
::
beforeDelete
())
{
if
(
$this
->
assigns
)
{
foreach
(
$this
->
assigns
as
$assign
)
{
$assign
->
delete
();
}
}
return
true
;
}
else
{
return
false
;
}
}
public
function
getUrl
()
public
function
getUrl
()
{
{
return
Url
::
to
([
'/blog/tag/'
.
$this
->
name
]);
return
Url
::
to
([
'/blog/tag/'
.
$this
->
name
]);
...
...
common/modules/blog/models/SearchPostTag.php
0 → 100644
View file @
ecfaca54
<?php
namespace
common\modules\blog\models
;
use
Yii
;
use
yii\base\Model
;
use
yii\data\ActiveDataProvider
;
use
common\modules\blog\models\PostTag
;
/**
* SearchPostTag represents the model behind the search form about `common\modules\blog\models\PostTag`.
*/
class
SearchPostTag
extends
PostTag
{
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
[[
'id'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'name'
],
'safe'
],
];
}
/**
* @inheritdoc
*/
public
function
scenarios
()
{
// bypass scenarios() implementation in the parent class
return
Model
::
scenarios
();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public
function
search
(
$params
)
{
$query
=
PostTag
::
find
();
// add conditions that should always apply here
$dataProvider
=
new
ActiveDataProvider
([
'query'
=>
$query
,
]);
$this
->
load
(
$params
);
if
(
!
$this
->
validate
())
{
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return
$dataProvider
;
}
// grid filtering conditions
$query
->
andFilterWhere
([
'id'
=>
$this
->
id
,
'created_at'
=>
$this
->
created_at
,
'updated_at'
=>
$this
->
updated_at
,
]);
$query
->
andFilterWhere
([
'like'
,
'name'
,
$this
->
name
]);
return
$dataProvider
;
}
}
common/modules/blog/views/post-admin/_form.php
View file @
ecfaca54
...
@@ -50,7 +50,7 @@ use common\modules\content\widgets\MetaTagsWidget;
...
@@ -50,7 +50,7 @@ use common\modules\content\widgets\MetaTagsWidget;
],
],
'triggerKeys'
=>
[
'enter'
,
'space'
,
'tab'
],
'triggerKeys'
=>
[
'enter'
,
'space'
,
'tab'
],
]
]
]);
?>
])
->
hint
(
'Пожалуйста используйте только следующие тэги: “Реклама”, “Аналитика”, “Секреты бизнеса”,”Для души”, “Гаджеты”, “Разработка”, "АртПроект"'
)
;
?>
<ul
class=
"nav nav-pills"
>
<ul
class=
"nav nav-pills"
>
<?php
$c
=
0
;
foreach
(
$model
->
getLangsHelper
()
as
$i
=>
$content
)
:
$c
++
;
?>
<?php
$c
=
0
;
foreach
(
$model
->
getLangsHelper
()
as
$i
=>
$content
)
:
$c
++
;
?>
...
...
common/modules/blog/views/post-admin/_search.php
deleted
100644 → 0
View file @
9dca5a70
<?php
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\SearchPost */
/* @var $form yii\widgets\ActiveForm */
?>
<div
class=
"post-search"
>
<?php
$form
=
ActiveForm
::
begin
([
'action'
=>
[
'index'
],
'method'
=>
'get'
,
]);
?>
<?=
$form
->
field
(
$model
,
'id'
)
?>
<?=
$form
->
field
(
$model
,
'url'
)
?>
<?=
$form
->
field
(
$model
,
'active'
)
?>
<?=
$form
->
field
(
$model
,
'created_at'
)
?>
<?=
$form
->
field
(
$model
,
'updated_at'
)
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Search'
,
[
'class'
=>
'btn btn-primary'
])
?>
<?=
Html
::
resetButton
(
'Reset'
,
[
'class'
=>
'btn btn-default'
])
?>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
common/modules/blog/views/tag-admin/_form.php
0 → 100644
View file @
ecfaca54
<?php
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
/* @var $form yii\widgets\ActiveForm */
?>
<div
class=
"post-tag-form"
>
<?php
$form
=
ActiveForm
::
begin
();
?>
<?=
$form
->
field
(
$model
,
'name'
)
->
textInput
([
'maxlength'
=>
true
])
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Сохранить'
,
[
'class'
=>
'btn btn-success'
])
?>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
common/modules/blog/views/tag-admin/create.php
0 → 100644
View file @
ecfaca54
<?php
use
yii\helpers\Html
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
$this
->
title
=
'Create Post Tag'
;
$this
->
params
[
'breadcrumbs'
][]
=
[
'label'
=>
'Post Tags'
,
'url'
=>
[
'index'
]];
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<div
class=
"post-tag-create"
>
<?=
$this
->
render
(
'_form'
,
[
'model'
=>
$model
,
])
?>
</div>
common/modules/blog/views/tag-admin/manage.php
0 → 100644
View file @
ecfaca54
<?php
use
yii\helpers\Html
;
use
yii\grid\GridView
;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\blog\models\SearchPostTag */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this
->
title
=
'Post Tags'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<div
class=
"post-tag-index"
>
<p>
<?=
Html
::
a
(
'Добавить'
,
[
'create'
],
[
'class'
=>
'btn btn-success'
])
?>
</p>
<?=
GridView
::
widget
([
'dataProvider'
=>
$dataProvider
,
'filterModel'
=>
$searchModel
,
'columns'
=>
[
// ['class' => 'yii\grid\SerialColumn'],
'name'
,
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{update} {delete}'
,
],
],
]);
?>
</div>
common/modules/blog/views/tag-admin/update.php
0 → 100644
View file @
ecfaca54
<?php
use
yii\helpers\Html
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
$this
->
title
=
'Update Post Tag: '
.
' '
.
$model
->
name
;
$this
->
params
[
'breadcrumbs'
][]
=
[
'label'
=>
'Post Tags'
,
'url'
=>
[
'index'
]];
$this
->
params
[
'breadcrumbs'
][]
=
[
'label'
=>
$model
->
name
,
'url'
=>
[
'view'
,
'id'
=>
$model
->
id
]];
$this
->
params
[
'breadcrumbs'
][]
=
'Update'
;
?>
<div
class=
"post-tag-update"
>
<?=
$this
->
render
(
'_form'
,
[
'model'
=>
$model
,
])
?>
</div>
common/modules/blog/views/tag-admin/view.php
0 → 100644
View file @
ecfaca54
<?php
use
yii\helpers\Html
;
use
yii\widgets\DetailView
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
$this
->
title
=
$model
->
name
;
$this
->
params
[
'breadcrumbs'
][]
=
[
'label'
=>
'Post Tags'
,
'url'
=>
[
'index'
]];
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<div
class=
"post-tag-view"
>
<p>
<?=
Html
::
a
(
'Редактировать'
,
[
'update'
,
'id'
=>
$model
->
id
],
[
'class'
=>
'btn btn-primary'
])
?>
<?=
Html
::
a
(
'Удалить'
,
[
'delete'
,
'id'
=>
$model
->
id
],
[
'class'
=>
'btn btn-danger'
,
'data'
=>
[
'confirm'
=>
'Are you sure you want to delete this item?'
,
'method'
=>
'post'
,
],
])
?>
</p>
<?=
DetailView
::
widget
([
'model'
=>
$model
,
'attributes'
=>
[
'name'
,
],
])
?>
</div>
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