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
9b54409d
Commit
9b54409d
authored
Feb 08, 2016
by
Shakarim Sapa
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
593155e4
3f08e2f2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
41 deletions
+91
-41
common/components/activeRecordBehaviors/MetaTagBehavior.php
common/components/activeRecordBehaviors/MetaTagBehavior.php
+9
-6
common/modules/content/components/CoBlocksLangBehavior.php
common/modules/content/components/CoBlocksLangBehavior.php
+8
-4
common/modules/content/components/CoContentLangBehavior.php
common/modules/content/components/CoContentLangBehavior.php
+8
-4
common/modules/content/controllers/ContentAdminController.php
...on/modules/content/controllers/ContentAdminController.php
+57
-18
common/modules/content/models/CoContent.php
common/modules/content/models/CoContent.php
+1
-1
common/modules/content/views/content-admin/index.php
common/modules/content/views/content-admin/index.php
+8
-8
No files found.
common/components/activeRecordBehaviors/MetaTagBehavior.php
View file @
9b54409d
...
...
@@ -12,7 +12,7 @@ class MetaTagBehavior extends Behavior
return
[
ActiveRecord
::
EVENT_AFTER_UPDATE
=>
'Save'
,
ActiveRecord
::
EVENT_AFTER_INSERT
=>
'Insert'
,
ActiveRecord
::
EVENT_
AFTER
_DELETE
=>
'Delete'
,
ActiveRecord
::
EVENT_
BEFORE
_DELETE
=>
'Delete'
,
];
}
...
...
@@ -69,11 +69,14 @@ class MetaTagBehavior extends Behavior
public
function
Delete
(
$event
)
{
MetaTags
::
deleteAll
([
'object_id'
=>
$this
->
owner
->
id
,
'model_id'
=>
get_class
(
$this
->
owner
)
]);
if
(
$this
->
owner
->
metaTags
)
{
foreach
(
$this
->
owner
->
metaTags
as
$meta
)
{
$meta
->
delete
();
}
}
return
true
;
}
}
common/modules/content/components/CoBlocksLangBehavior.php
View file @
9b54409d
...
...
@@ -13,7 +13,7 @@ class CoBlocksLangBehavior extends Behavior
return
[
ActiveRecord
::
EVENT_AFTER_UPDATE
=>
'Save'
,
ActiveRecord
::
EVENT_AFTER_INSERT
=>
'Insert'
,
ActiveRecord
::
EVENT_
AFTER
_DELETE
=>
'Delete'
,
ActiveRecord
::
EVENT_
BEFORE
_DELETE
=>
'Delete'
,
];
}
...
...
@@ -67,9 +67,13 @@ class CoBlocksLangBehavior extends Behavior
public
function
Delete
(
$event
)
{
CoBlocksLang
::
deleteAll
([
'block_id'
=>
$this
->
owner
->
id
]);
if
(
$this
->
owner
->
langs
)
{
foreach
(
$this
->
owner
->
langs
as
$lang
)
{
$lang
->
delete
();
}
}
return
true
;
}
...
...
common/modules/content/components/CoContentLangBehavior.php
View file @
9b54409d
...
...
@@ -13,7 +13,7 @@ class CoContentLangBehavior extends Behavior
return
[
ActiveRecord
::
EVENT_AFTER_UPDATE
=>
'Save'
,
ActiveRecord
::
EVENT_AFTER_INSERT
=>
'Insert'
,
ActiveRecord
::
EVENT_
AFTER
_DELETE
=>
'Delete'
,
ActiveRecord
::
EVENT_
BEFORE
_DELETE
=>
'Delete'
,
];
}
...
...
@@ -67,9 +67,13 @@ class CoContentLangBehavior extends Behavior
public
function
Delete
(
$event
)
{
CoContentLang
::
deleteAll
([
'content_id'
=>
$this
->
owner
->
id
]);
if
(
$this
->
owner
->
langs
)
{
foreach
(
$this
->
owner
->
langs
as
$lang
)
{
$lang
->
delete
();
}
}
return
true
;
}
...
...
common/modules/content/controllers/ContentAdminController.php
View file @
9b54409d
...
...
@@ -28,7 +28,7 @@ class ContentAdminController extends AdminController
'Update'
=>
'Редактирование контента'
,
'Delete'
=>
'Удаление контента'
,
'View'
=>
'Просмотр контента'
,
// 'Copy' => '
',
'Copy'
=>
'Копирование страниц
'
,
];
}
...
...
@@ -44,23 +44,6 @@ class ContentAdminController extends AdminController
];
}
// public function actionCopy($id)
// {
// $model = $this->findModel($id);
// $meta = $model->metaTags->attributes;
// \Yii::$app->request->setBodyParams(['MetaTags' => $meta]);
// $newPage = new CoContent();
// $data = $model->attributes;
// unset($data['id']);
// $data['url'] = '';
// $newPage->setAttributes($data);
// $newPage->name .= ' (Копия)';
// $newPage->save(false);
// $this->redirect(['manage']);
// }
/**
* Lists all CoContent models.
* @return mixed
...
...
@@ -256,6 +239,62 @@ class ContentAdminController extends AdminController
return
$this
->
redirect
([
'manage'
]);
}
public
function
actionCopy
(
$id
)
{
$model
=
$this
->
findModel
(
$id
);
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
$copy
=
new
CoContent
();
$data
=
$model
->
attributes
;
unset
(
$data
[
'id'
]);
$copy
->
setAttributes
(
$data
);
$copy
->
save
(
false
);
if
(
$model
->
metaTags
)
{
foreach
(
$model
->
metaTags
as
$mt
)
{
$mtn
=
new
\common\models\MetaTags
;
$data
=
$mt
->
attributes
;
unset
(
$data
[
'id'
]);
$mtn
->
setAttributes
(
$data
);
$mtn
->
object_id
=
$copy
->
id
;
$mtn
->
save
(
false
);
}
}
if
(
$model
->
langs
)
{
foreach
(
$model
->
langs
as
$lang
)
{
$lng
=
new
CoContentLang
;
$data
=
$lang
->
attributes
;
unset
(
$data
[
'id'
]);
$lng
->
setAttributes
(
$data
);
$lng
->
name
.=
' (Копия)'
;
$lng
->
content_id
=
$copy
->
id
;
$lng
->
save
(
false
);
}
}
$transaction
->
commit
();
}
catch
(
Exception
$e
)
{
$transaction
->
rollBack
();
throw
$e
;
}
$this
->
redirect
([
'manage'
]);
}
/**
* Finds the CoContent model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
...
...
common/modules/content/models/CoContent.php
View file @
9b54409d
...
...
@@ -125,7 +125,7 @@ class CoContent extends \common\components\ActiveRecordModel
*/
public
function
getMetaTags
(
$lang_id
=
null
)
{
$query
=
$this
->
has
One
(
MetaTags
::
className
(),
[
'object_id'
=>
'id'
])
->
where
([
'model_id'
=>
get_class
(
$this
)]);
$query
=
$this
->
has
Many
(
MetaTags
::
className
(),
[
'object_id'
=>
'id'
])
->
where
([
'model_id'
=>
get_class
(
$this
)]);
if
(
$lang_id
)
{
...
...
common/modules/content/views/content-admin/index.php
View file @
9b54409d
...
...
@@ -43,15 +43,15 @@ 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>';
//
},
'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>'
;
},
],
],
],
...
...
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