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
e4a4094a
Commit
e4a4094a
authored
Feb 16, 2016
by
Виталий Мурашко
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add social sharing
parent
8ae3ec80
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
177 additions
and
13 deletions
+177
-13
common/modules/school/controllers/LessonController.php
common/modules/school/controllers/LessonController.php
+4
-0
common/modules/school/controllers/StatisticsController.php
common/modules/school/controllers/StatisticsController.php
+35
-0
common/modules/school/models/Courses.php
common/modules/school/models/Courses.php
+1
-1
common/modules/school/models/Lessons.php
common/modules/school/models/Lessons.php
+1
-1
common/modules/school/models/UserStatistics.php
common/modules/school/models/UserStatistics.php
+54
-0
common/modules/school/views/course/index.php
common/modules/school/views/course/index.php
+20
-1
common/modules/school/views/lesson/view.php
common/modules/school/views/lesson/view.php
+25
-9
console/migrations/m160215_210504_user_statistics.php
console/migrations/m160215_210504_user_statistics.php
+37
-0
frontend/web/js/common.js
frontend/web/js/common.js
+0
-1
No files found.
common/modules/school/controllers/LessonController.php
View file @
e4a4094a
...
@@ -18,6 +18,10 @@ class LessonController extends BaseController
...
@@ -18,6 +18,10 @@ class LessonController extends BaseController
public
function
actionView
(
$id
)
public
function
actionView
(
$id
)
{
{
$model
=
Lessons
::
findOne
(
$id
);
$model
=
Lessons
::
findOne
(
$id
);
\Yii
::
$app
->
view
->
registerMetaTag
([
'property'
=>
'og:title'
,
'content'
=>
$model
->
title
]);
return
$this
->
render
(
'view'
,
[
'model'
=>
$model
]);
return
$this
->
render
(
'view'
,
[
'model'
=>
$model
]);
}
}
}
}
common/modules/school/controllers/StatisticsController.php
0 → 100644
View file @
e4a4094a
<?php
namespace
common\modules\school\controllers
;
use
common\components\BaseController
;
use
common\modules\school\models\UserStatistics
;
class
StatisticsController
extends
BaseController
{
public
static
function
actionsTitles
()
{
return
[
'Shares'
=>
'Публикации в соцсетях'
,
];
}
public
function
actionShares
()
{
if
(
!
\Yii
::
$app
->
user
->
isGuest
){
$nameSoc
=
$_POST
[
'name'
];
$lessonId
=
$_POST
[
'lesson'
]
?
$_POST
[
'lesson'
]
:
UserStatistics
::
NOT_LESSON
;
$userId
=
\Yii
::
$app
->
user
->
id
;
$shareUser
=
UserStatistics
::
findOne
([
$nameSoc
=>
UserStatistics
::
SELECTED_SOC_NETWORK
,
'user_id'
=>
$userId
,
'lesson_id'
=>
$lessonId
]);
if
(
!
$shareUser
){
$shareUser
=
new
UserStatistics
();
$shareUser
->
{
$nameSoc
}
=
UserStatistics
::
SELECTED_SOC_NETWORK
;
$shareUser
->
user_id
=
$userId
;
$shareUser
->
lesson_id
=
$lessonId
;
$shareUser
->
save
();
}
}
}
}
common/modules/school/models/Courses.php
View file @
e4a4094a
...
@@ -55,7 +55,7 @@ class Courses extends \common\components\ActiveRecordModel
...
@@ -55,7 +55,7 @@ class Courses extends \common\components\ActiveRecordModel
{
{
return
[
return
[
[[
'title'
,
'description'
,
'type'
],
'required'
],
[[
'title'
,
'description'
,
'type'
],
'required'
],
[[
'type'
,
'spec_proposition'
],
'integer'
,
'max'
=>
11
],
[[
'type'
,
'spec_proposition'
],
'integer'
],
[[
'title'
],
'string'
,
'max'
=>
150
],
[[
'title'
],
'string'
,
'max'
=>
150
],
[[
'image'
],
'string'
,
'max'
=>
100
],
[[
'image'
],
'string'
,
'max'
=>
100
],
[[
'description'
,
'description_for_course'
],
'safe'
],
[[
'description'
,
'description_for_course'
],
'safe'
],
...
...
common/modules/school/models/Lessons.php
View file @
e4a4094a
...
@@ -39,7 +39,7 @@ class Lessons extends \common\components\ActiveRecordModel
...
@@ -39,7 +39,7 @@ class Lessons extends \common\components\ActiveRecordModel
[[
'title'
,
'video_id'
,
'course_id'
,
'number'
],
'required'
],
[[
'title'
,
'video_id'
,
'course_id'
,
'number'
],
'required'
],
[[
'title'
],
'string'
,
'max'
=>
150
],
[[
'title'
],
'string'
,
'max'
=>
150
],
[[
'video_id'
],
'string'
,
'max'
=>
100
],
[[
'video_id'
],
'string'
,
'max'
=>
100
],
[[
'course_id'
,
'number'
],
'integer'
,
'max'
=>
11
],
[[
'course_id'
,
'number'
],
'integer'
],
[[
'text'
],
'safe'
],
[[
'text'
],
'safe'
],
];
];
}
}
...
...
common/modules/school/models/UserStatistics.php
0 → 100644
View file @
e4a4094a
<?php
namespace
common\modules\school\models
;
class
UserStatistics
extends
\common\components\ActiveRecordModel
{
const
NOT_LESSON
=
0
;
const
SELECTED_SOC_NETWORK
=
1
;
public
static
function
tableName
()
{
return
'user_statistics'
;
}
public
function
name
()
{
return
'Публикации в соцсетях'
;
}
public
function
attributeLabels
()
{
return
[
'lesson_id'
=>
'Урок'
,
'user_id'
=>
'Пользователь'
,
'facebook'
=>
'Facebook'
,
'vkontakte'
=>
'Вконтакте'
,
'gplus'
=>
'Google+'
,
'twitter'
=>
'Twitter'
,
'tumblr'
=>
'Tumblr'
,
];
}
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
[[
'user_id'
],
'required'
],
[[
'lesson_id'
,
'user_id'
,
'facebook'
,
'vkontakte'
,
'gplus'
,
'twitter'
,
'tumblr'
],
'integer'
],
];
}
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
];
}
}
common/modules/school/views/course/index.php
View file @
e4a4094a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
//use kartik\social\FacebookPlugin;
//use kartik\social\FacebookPlugin;
//echo FacebookPlugin::widget(['appId'=>'FACEBOOK_APP_ID']);
//echo FacebookPlugin::widget(['appId'=>'FACEBOOK_APP_ID']);
use
common\modules\school\assets\WidgetAssetBundle
;
use
common\modules\school\assets\WidgetAssetBundle
;
use
yii\web\View
;
WidgetAssetBundle
::
register
(
$this
);
WidgetAssetBundle
::
register
(
$this
);
...
@@ -26,7 +27,25 @@ WidgetAssetBundle::register($this);
...
@@ -26,7 +27,25 @@ WidgetAssetBundle::register($this);
<div
class=
"sh_social"
>
<div
class=
"sh_social"
>
<script
type=
"text/javascript"
src=
"//yastatic.net/es5-shims/0.0.2/es5-shims.min.js"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"//yastatic.net/es5-shims/0.0.2/es5-shims.min.js"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"//yastatic.net/share2/share.js"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"//yastatic.net/share2/share.js"
charset=
"utf-8"
></script>
<div
class=
"ya-share2"
data-services=
"vkontakte,facebook,gplus,twitter,tumblr"
data-title=
"Школа аналитики"
></div>
<div
id=
"my-share"
></div>
<?php
$this
->
registerJs
(
"Ya.share2('#my-share', {
hooks: {
onshare: function (name) {
$.ajax({
type: 'POST',
url: '/school/statistics/shares',
data: {'name': name},
success: function(data){}
});
}
},
theme: {
services: 'vkontakte,facebook,gplus,twitter,tumblr'
},
content: {
title: 'Школа аналитики',
}
});"
,
View
::
POS_END
,
'my-options'
);
?>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
common/modules/school/views/lesson/view.php
View file @
e4a4094a
<?php
<?php
use
common\modules\users\widgets\UserBoxWidget
;
use
common\modules\users\widgets\UserBoxWidget
;
use
common\modules\school\assets\WidgetAssetBundle
;
use
common\modules\school\assets\WidgetAssetBundle
;
use
yii\web\View
;
WidgetAssetBundle
::
register
(
$this
);
WidgetAssetBundle
::
register
(
$this
);
?>
?>
...
@@ -27,15 +28,30 @@ WidgetAssetBundle::register($this);
...
@@ -27,15 +28,30 @@ WidgetAssetBundle::register($this);
<h1
class=
"vc-title"
>
Урок
<?php
echo
$model
->
number
;
?>
.
<?php
echo
$model
->
title
;
?>
</h1>
<h1
class=
"vc-title"
>
Урок
<?php
echo
$model
->
number
;
?>
.
<?php
echo
$model
->
title
;
?>
</h1>
</div>
</div>
<div
class=
"col-md-3 col-md-offset-1 col-xs-4 col-sm-12"
>
<div
class=
"col-md-3 col-md-offset-1 col-xs-4 col-sm-12"
>
<ul
class=
"sh_social"
>
<div
class=
"sh_social"
>
<li>
<script
type=
"text/javascript"
src=
"//yastatic.net/es5-shims/0.0.2/es5-shims.min.js"
charset=
"utf-8"
></script>
<a
href=
"#"
><img
src=
"/images/icon/sh_social_vk.png"
height=
"30"
width=
"30"
alt=
""
></a>
<script
type=
"text/javascript"
src=
"//yastatic.net/share2/share.js"
charset=
"utf-8"
></script>
<a
href=
"#"
><img
src=
"/images/icon/sh_social_fb.png"
height=
"30"
width=
"30"
alt=
""
></a>
<div
id=
"my-share"
></div>
<a
href=
"#"
><img
src=
"/images/icon/sh_social_tw.png"
height=
"30"
width=
"30"
alt=
""
></a>
<?php
$this
->
registerJs
(
"Ya.share2('#my-share', {
<a
href=
"#"
><img
src=
"/images/icon/sh_social_gp.png"
height=
"30"
width=
"30"
alt=
""
></a>
hooks: {
<a
href=
"#"
><img
src=
"/images/icon/sh_social_t.png"
height=
"30"
width=
"30"
alt=
""
></a>
onshare: function (name) {
</li>
lesson = "
.
$model
->
id
.
";
</ul>
$.ajax({
type: 'POST',
url: '/school/statistics/shares',
data: {'name': name, 'lesson': lesson},
success: function(data){}
});
}
},
theme: {
services: 'vkontakte,facebook,gplus,twitter,tumblr'
},
content: {
title: 'Школа аналитики',
}
});"
,
View
::
POS_END
,
'my-options'
);
?>
</div>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
...
...
console/migrations/m160215_210504_user_statistics.php
0 → 100644
View file @
e4a4094a
<?php
use
yii\db\Schema
;
use
yii\db\Migration
;
class
m160215_210504_user_statistics
extends
Migration
{
public
function
safeUp
()
{
$tableOptions
=
null
;
if
(
$this
->
db
->
driverName
===
'mysql'
)
{
$tableOptions
=
'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'
;
}
// Структура таблицы `user_statistics`
$this
->
createTable
(
'user_statistics'
,
[
'id'
=>
Schema
::
TYPE_PK
,
'lesson_id'
=>
Schema
::
TYPE_INTEGER
.
'(11)'
,
'user_id'
=>
Schema
::
TYPE_INTEGER
.
'(11) NOT NULL'
,
'facebook'
=>
Schema
::
TYPE_INTEGER
.
'(11)'
,
'vkontakte'
=>
Schema
::
TYPE_INTEGER
.
'(11)'
,
'gplus'
=>
Schema
::
TYPE_INTEGER
.
'(11)'
,
'twitter'
=>
Schema
::
TYPE_INTEGER
.
'(11)'
,
'tumblr'
=>
Schema
::
TYPE_INTEGER
.
'(11)'
,
],
$tableOptions
);
$this
->
createIndex
(
'FK_user_statistics_users'
,
'user_statistics'
,
'user_id'
);
$this
->
createIndex
(
'FK_user_statistics_lessons'
,
'user_statistics'
,
'lesson_id'
);
}
public
function
safeDown
()
{
$this
->
dropTable
(
'user_statistics'
);
}
}
frontend/web/js/common.js
View file @
e4a4094a
...
@@ -388,7 +388,6 @@ $(document).ready(function() {
...
@@ -388,7 +388,6 @@ $(document).ready(function() {
$
(
"
.menu
"
).
removeClass
(
"
menu_active
"
);
$
(
"
.menu
"
).
removeClass
(
"
menu_active
"
);
$
(
"
.toggle-mnu
"
).
removeClass
(
"
on
"
);
$
(
"
.toggle-mnu
"
).
removeClass
(
"
on
"
);
});
});
});
});
$
(
window
).
load
(
function
()
{
$
(
window
).
load
(
function
()
{
...
...
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