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
2ca21ed0
Commit
2ca21ed0
authored
Mar 14, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1067 - Функция коппи блоков страниц
parent
d2403a38
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
48 deletions
+87
-48
common/modules/content/controllers/BlockAdminController.php
common/modules/content/controllers/BlockAdminController.php
+43
-1
common/modules/content/controllers/ContentAdminController.php
...on/modules/content/controllers/ContentAdminController.php
+25
-40
common/modules/content/models/CoBlocks.php
common/modules/content/models/CoBlocks.php
+2
-1
common/modules/content/models/CoContent.php
common/modules/content/models/CoContent.php
+4
-2
common/modules/content/views/block-admin/index.php
common/modules/content/views/block-admin/index.php
+12
-3
common/modules/languages/components/LanguageHelperBehavior.php
...n/modules/languages/components/LanguageHelperBehavior.php
+1
-1
No files found.
common/modules/content/controllers/BlockAdminController.php
View file @
2ca21ed0
...
...
@@ -22,6 +22,7 @@ class BlockAdminController extends AdminController
'Manage'
=>
'Управление блоками'
,
'Create'
=>
'Добавление блока'
,
'Update'
=>
'Редактирование блока'
,
'Copy'
=>
'Копирование блока'
,
'Delete'
=>
'Удаление блока'
,
'View'
=>
'Просмотр блока'
,
];
...
...
@@ -156,6 +157,47 @@ class BlockAdminController extends AdminController
]);
}
public
function
actionCopy
(
$id
)
{
$model
=
$this
->
findModel
(
$id
);
$model
->
name
=
$model
->
title
=
null
;
Yii
::
$app
->
controller
->
page_title
=
'Копировать блок'
;
Yii
::
$app
->
controller
->
breadcrumbs
=
[
[
'Управление блоками'
=>
\yii\helpers\Url
::
toRoute
(
'manage'
)],
'Копировать блок'
,
];
if
(
Yii
::
$app
->
request
->
isPost
)
{
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
$model
=
new
CoBlocks
;
$model
->
attributes
=
Yii
::
$app
->
request
->
post
(
'CoBlocks'
);
if
(
$model
->
save
())
{
$transaction
->
commit
();
return
$this
->
redirect
([
'manage'
]);
}
}
catch
(
\Exception
$e
)
{
$transaction
->
rollBack
();
throw
$e
;
}
}
return
$this
->
render
(
'update'
,
[
'model'
=>
$model
,
]);
}
/**
* Deletes an existing CoBlocks model.
* If deletion is successful, the browser will be redirected to the 'index' page.
...
...
common/modules/content/controllers/ContentAdminController.php
View file @
2ca21ed0
...
...
@@ -178,56 +178,41 @@ class ContentAdminController extends AdminController
{
$model
=
$this
->
findModel
(
$id
);
$
transaction
=
Yii
::
$app
->
db
->
beginTransaction
()
;
$
model
->
url
=
null
;
try
{
$copy
=
new
CoContent
();
Yii
::
$app
->
controller
->
page_title
=
'Копирование страницы'
;
$data
=
$model
->
attributes
;
unset
(
$data
[
'id'
]);
$
copy
->
setAttributes
(
$data
);
$copy
->
save
(
false
)
;
Yii
::
$app
->
controller
->
breadcrumbs
=
[
[
'Управление контентом'
=>
\yii\helpers\Url
::
toRoute
(
'manage'
)],
$
model
->
url
,
]
;
if
(
$model
->
metaTags
)
{
foreach
(
$model
->
metaTags
as
$mt
)
if
(
Yii
::
$app
->
request
->
isPost
)
{
$mtn
=
new
\common\models\MetaTags
;
$data
=
$mt
->
attributes
;
unset
(
$data
[
'id'
]);
$mtn
->
setAttributes
(
$data
);
$mtn
->
object_id
=
$copy
->
id
;
$mtn
->
save
(
false
);
}
}
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
if
(
$model
->
langs
)
{
foreach
(
$model
->
langs
as
$lang
)
try
{
$lng
=
new
CoContentLang
;
$model
=
new
CoContent
;
$data
=
$lang
->
attributes
;
unset
(
$data
[
'id'
]);
$lng
->
setAttributes
(
$data
);
$lng
->
name
.=
' (Копия)'
;
$lng
->
content_id
=
$copy
->
id
;
$lng
->
save
(
false
);
}
}
$model
->
attributes
=
Yii
::
$app
->
request
->
post
(
'CoContent'
);
if
(
$model
->
save
())
{
$transaction
->
commit
();
return
$this
->
redirect
([
'manage'
]);
}
catch
(
Exception
$e
)
}
catch
(
\Exception
$e
)
{
$transaction
->
rollBack
();
throw
$e
;
}
}
$this
->
redirect
([
'manage'
]);
return
$this
->
render
(
'update'
,
[
'model'
=>
$model
,
]);
}
/**
...
...
common/modules/content/models/CoBlocks.php
View file @
2ca21ed0
...
...
@@ -43,7 +43,7 @@ class CoBlocks extends \common\components\ActiveRecordModel
'class'
=>
'common\modules\languages\components\LanguageHelperBehavior'
,
'field'
=>
'block_id'
,
'langClass'
=>
'common\modules\content\models\CoBlocksLang'
,
'actions'
=>
[
'create'
,
'update'
]
'actions'
=>
[
'create'
,
'update'
,
'copy'
]
],
];
}
...
...
@@ -55,6 +55,7 @@ class CoBlocks extends \common\components\ActiveRecordModel
{
return
[
[[
'title'
,
'name'
],
'required'
],
[[
'title'
],
'unique'
],
[[
'category_id'
],
'safe'
],
[[
'title'
],
'string'
,
'max'
=>
250
],
[[
'name'
],
'string'
,
'max'
=>
50
],
...
...
common/modules/content/models/CoContent.php
View file @
2ca21ed0
...
...
@@ -32,6 +32,8 @@ class CoContent extends \common\components\ActiveRecordModel
const
CUSTOM_DARK
=
'dark'
;
const
CUSTOM_WHITE
=
'white'
;
public
$copyLangs
;
public
static
$cutom_list
=
[
self
::
CUSTOM_DARK
=>
'Темный'
,
self
::
CUSTOM_WHITE
=>
'Светлый'
,
...
...
@@ -53,13 +55,13 @@ class CoContent extends \common\components\ActiveRecordModel
return
[
'meta'
=>
[
'class'
=>
'common\components\activeRecordBehaviors\MetaTagBehavior'
,
'actions'
=>
[
'create'
,
'update'
]
'actions'
=>
[
'create'
,
'update'
,
'copy'
]
],
'langs'
=>
[
'class'
=>
'common\modules\languages\components\LanguageHelperBehavior'
,
'field'
=>
'content_id'
,
'langClass'
=>
'common\modules\content\models\CoContentLang'
,
'actions'
=>
[
'create'
,
'update'
]
'actions'
=>
[
'create'
,
'update'
,
'copy'
]
],
'file'
=>
[
'class'
=>
'common\components\activeRecordBehaviors\FileUploadBehavior'
,
...
...
common/modules/content/views/block-admin/index.php
View file @
2ca21ed0
<?php
use
yii\helpers\Html
;
use
yii\helpers\Url
;
use
\yii\helpers\ArrayHelper
;
use
\common\modules\content\models\CoCategory
;
/* @var $this yii\web\View */
...
...
@@ -44,9 +45,17 @@ use \common\modules\content\models\CoCategory;
[
'class'
=>
'common\components\ColorActionColumn'
,
'template'
=>
'{update} {delete}'
,
]
,
'template'
=>
'{copy} {update} {delete}'
,
'buttons'
=>
[
'copy'
=>
function
(
$url
,
$model
,
$key
)
{
return
'<a href="'
.
Url
::
toRoute
([
'copy'
,
'id'
=>
$model
->
id
])
.
'">'
.
Html
::
beginTag
(
'i'
,
[
'title'
=>
"Копировать блок"
,
'data-toggle'
=>
'tooltip'
,
'class'
=>
'fa fa-copy fa-lg'
])
.
Html
::
endTag
(
'i'
)
.
'</a>'
;
},
],
],
],
]);
?>
...
...
common/modules/languages/components/LanguageHelperBehavior.php
View file @
2ca21ed0
...
...
@@ -133,7 +133,7 @@ class LanguageHelperBehavior extends Behavior
public
function
Delete
(
$event
)
{
if
(
$this
->
owner
->
langs
)
if
(
isset
(
$this
->
owner
->
langs
)
)
{
foreach
(
$this
->
owner
->
langs
as
$lang
)
{
...
...
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