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
6f1a9058
Commit
6f1a9058
authored
Mar 22, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1103 - Правки английской версии 0.1
parent
b79ad8d2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
140 additions
and
17 deletions
+140
-17
common/modules/blog/models/Post.php
common/modules/blog/models/Post.php
+16
-1
common/modules/blog/models/PostTag.php
common/modules/blog/models/PostTag.php
+17
-1
common/modules/blog/models/PostTagQuery.php
common/modules/blog/models/PostTagQuery.php
+45
-0
common/modules/blog/views/post/_sidebar.php
common/modules/blog/views/post/_sidebar.php
+24
-15
common/modules/blog/views/tag-admin/_form.php
common/modules/blog/views/tag-admin/_form.php
+5
-0
common/modules/blog/views/tag-admin/manage.php
common/modules/blog/views/tag-admin/manage.php
+12
-0
common/modules/blog/views/tag-admin/view.php
common/modules/blog/views/tag-admin/view.php
+4
-0
console/migrations/m160322_103650_blog_tag_language.php
console/migrations/m160322_103650_blog_tag_language.php
+17
-0
No files found.
common/modules/blog/models/Post.php
View file @
6f1a9058
...
...
@@ -185,7 +185,22 @@ class Post extends \common\components\ActiveRecordModel
*/
public
function
getPostTags
()
{
return
$this
->
hasMany
(
PostTag
::
className
(),
[
'id'
=>
'tag_id'
])
->
viaTable
(
'posts_tags_assign'
,
[
'post_id'
=>
'id'
]);
$lang
=
Languages
::
getCurrent
();
$query
=
$this
->
hasMany
(
PostTag
::
className
(),
[
'id'
=>
'tag_id'
])
->
viaTable
(
'posts_tags_assign'
,
[
'post_id'
=>
'id'
]);
if
(
$lang
->
default
)
{
$query
=
$query
->
andWhere
(
'lang_id = '
.
$lang
->
id
.
' OR lang_id IS NULL'
);
}
else
{
$query
=
$query
->
andWhere
([
'lang_id'
=>
$lang
->
id
]);
}
return
$query
;
}
/**
...
...
common/modules/blog/models/PostTag.php
View file @
6f1a9058
...
...
@@ -42,7 +42,8 @@ class PostTag extends \common\components\ActiveRecordModel
{
return
[
[[
'name'
],
'required'
],
[[
'created_at'
,
'updated_at'
],
'integer'
],
[[
'lang_id'
],
'safe'
],
[[
'created_at'
,
'updated_at'
,
'lang_id'
],
'integer'
],
[[
'name'
],
'string'
,
'max'
=>
255
],
];
}
...
...
@@ -55,6 +56,7 @@ class PostTag extends \common\components\ActiveRecordModel
return
[
'id'
=>
'ID'
,
'name'
=>
'Имя тега'
,
'lang_id'
=>
'Язык'
,
'created_at'
=>
'Дата добавления'
,
'updated_at'
=>
'Дата обновления'
,
];
...
...
@@ -83,6 +85,14 @@ class PostTag extends \common\components\ActiveRecordModel
->
orderBy
(
Post
::
tableName
()
.
'.created_at DESC'
);
}
/**
* @return \yii\db\ActiveQuery
*/
public
function
getLang
()
{
return
$this
->
hasOne
(
Languages
::
className
(),
[
'id'
=>
'lang_id'
]);
}
/**
* @return \yii\db\ActiveQuery
*/
...
...
@@ -115,4 +125,10 @@ class PostTag extends \common\components\ActiveRecordModel
{
return
Url
::
to
([
'/blog/tag/'
.
$this
->
name
]);
}
public
static
function
find
()
{
// use CustomerQuery instead of the default ActiveQuery
return
new
PostTagQuery
(
get_called_class
());
}
}
common/modules/blog/models/PostTagQuery.php
0 → 100644
View file @
6f1a9058
<?php
namespace
common\modules\blog\models
;
use
common\modules\languages\models\Languages
;
/**
* This is the ActiveQuery class for [[PostTag]].
*
* @see PostTag
*/
class
PostTagQuery
extends
\yii\db\ActiveQuery
{
public
function
currentLang
()
{
$lang
=
Languages
::
getCurrent
();
if
(
$lang
->
default
)
{
return
$this
->
andWhere
(
'lang_id = '
.
$lang
->
id
.
' OR lang_id IS NULL'
);
}
return
$this
->
andWhere
([
'lang_id'
=>
$lang
->
id
]);
}
/**
* @inheritdoc
* @return PostTag[]|array
*/
public
function
all
(
$db
=
null
)
{
return
parent
::
all
(
$db
);
}
/**
* @inheritdoc
* @return PostTag|array|null
*/
public
function
one
(
$db
=
null
)
{
return
parent
::
one
(
$db
);
}
}
common/modules/blog/views/post/_sidebar.php
View file @
6f1a9058
...
...
@@ -5,23 +5,30 @@ use yii\helpers\Url;
use
common\modules\blog\models\Post
;
use
common\modules\blog\models\PostTag
;
use
common\models\Settings
;
use
common\modules\languages\models\Languages
;
?>
<div
class=
"col-md-4 col-xs-4 col-sm-12"
>
<aside
class=
"sidebar"
>
<div
class=
"sidebar_module"
>
<h2>
<?=
\Yii
::
t
(
'blog'
,
'Categories'
);
?>
</h2>
<div
class=
"sidebar_module_body"
>
<?php
$tags
=
PostTag
::
find
()
<?php
$tags
=
PostTag
::
find
()
->
innerJoinWith
(
'posts'
)
->
groupBy
([
'posts_tags_assign.tag_id'
])
->
where
([
'posts.active'
=>
1
])
->
currentLang
()
->
orderBy
(
'RAND()'
)
->
limit
(
7
)
->
all
();
foreach
(
$tags
as
$tag
)
:
?>
?>
<?php
if
(
$tags
)
:
?>
<div
class=
"sidebar_module"
>
<h2>
<?=
\Yii
::
t
(
'blog'
,
'Categories'
);
?>
</h2>
<div
class=
"sidebar_module_body"
>
<?php
foreach
(
$tags
as
$tag
)
:
?>
<a
href=
"
<?=
$tag
->
url
;
?>
"
class=
"cat_link_mod"
>
<?=
$tag
->
name
?>
</a>
...
...
@@ -29,6 +36,8 @@ use common\models\Settings;
</div>
</div>
<?php
endif
;
?>
<div
class=
"sidebar_module"
>
<div
class=
"sidebar_module_body"
>
<a
href=
"#feedback"
class=
"sidebar_btn popup-form"
>
...
...
common/modules/blog/views/tag-admin/_form.php
View file @
6f1a9058
<?php
use
yii\helpers\Html
;
use
yii\helpers\ArrayHelper
;
use
yii\widgets\ActiveForm
;
use
common\modules\languages\models\Languages
;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
/* @var $form yii\widgets\ActiveForm */
...
...
@@ -14,6 +17,8 @@ use yii\widgets\ActiveForm;
<?=
$form
->
field
(
$model
,
'name'
)
->
textInput
([
'maxlength'
=>
true
])
?>
<?=
$form
->
field
(
$model
,
'lang_id'
)
->
dropDownList
(
ArrayHelper
::
map
(
Languages
::
find
()
->
all
(),
'id'
,
'name'
))
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Сохранить'
,
[
'class'
=>
'btn btn-success'
])
?>
</div>
...
...
common/modules/blog/views/tag-admin/manage.php
View file @
6f1a9058
...
...
@@ -3,6 +3,8 @@
use
yii\helpers\Html
;
use
yii\grid\GridView
;
use
common\modules\languages\models\Languages
;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\blog\models\SearchPostTag */
/* @var $dataProvider yii\data\ActiveDataProvider */
...
...
@@ -22,7 +24,17 @@ $this->params['breadcrumbs'][] = $this->title;
// ['class' => 'yii\grid\SerialColumn'],
'name'
,
[
'attribute'
=>
'lang_id'
,
'value'
=>
function
(
$model
)
{
if
(
$model
->
lang
)
{
return
$model
->
lang
->
name
;
}
return
Languages
::
getCurrent
()
->
name
;
}
],
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{update} {delete}'
,
...
...
common/modules/blog/views/tag-admin/view.php
View file @
6f1a9058
...
...
@@ -26,6 +26,10 @@ $this->params['breadcrumbs'][] = $this->title;
'model'
=>
$model
,
'attributes'
=>
[
'name'
,
[
'attribute'
=>
'lang_id'
,
'value'
=>
$model
->
lang
->
name
,
]
],
])
?>
...
...
console/migrations/m160322_103650_blog_tag_language.php
0 → 100644
View file @
6f1a9058
<?php
use
yii\db\Schema
;
use
yii\db\Migration
;
class
m160322_103650_blog_tag_language
extends
Migration
{
public
function
up
()
{
$this
->
addColumn
(
'posts_tags'
,
'lang_id'
,
Schema
::
TYPE_INTEGER
.
'(11) DEFAULT NULL AFTER name'
);
}
public
function
down
()
{
$this
->
dropColumn
(
'posts_tags'
,
'lang_id'
);
}
}
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