Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
339e7a1e
Commit
339e7a1e
authored
Oct 26, 2016
by
汪波
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # ui/html/index-play.html
parents
02b6d1c7
7364a947
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
692 additions
and
380 deletions
+692
-380
main.php
src/backend/config/main.php
+1
-1
ClassesController.php
src/backend/controllers/ClassesController.php
+19
-0
CourseController.php
src/backend/controllers/CourseController.php
+25
-1
SiteController.php
src/backend/controllers/SiteController.php
+16
-3
LoginForm.php
src/backend/models/LoginForm.php
+113
-0
User.php
src/backend/models/User.php
+103
-0
detail.php
src/backend/views/course/detail.php
+14
-0
back.php
src/backend/views/layouts/back.php
+199
-286
lte.php
src/backend/views/layouts/lte.php
+0
-4
login.php
src/backend/views/site/login.php
+42
-25
Qiniu.php
src/common/components/Qiniu.php
+1
-1
QiniuTranscode.php
src/common/libs/QiniuTranscode.php
+12
-19
User.php
src/common/models/User.php
+1
-1
params-local.php
src/environments/dev/common/config/params-local.php
+2
-1
params-local.php
src/environments/prod/common/config/params-local.php
+2
-1
HomeController.php
src/frontend/controllers/HomeController.php
+64
-9
QiniuCallbackController.php
src/frontend/controllers/QiniuCallbackController.php
+2
-0
preview.php
src/frontend/views/home/preview.php
+31
-0
video.php
src/frontend/views/home/video.php
+0
-3
index.php
src/frontend/views/my-course/index.php
+0
-1
video-intro.vue
src/frontend/web/js/home/components/video-intro.vue
+3
-1
video-play.vue
src/frontend/web/js/home/components/video-play.vue
+40
-19
index-play.html
ui/html/index-play.html
+2
-4
No files found.
src/backend/config/main.php
View file @
339e7a1e
...
@@ -17,7 +17,7 @@ return [
...
@@ -17,7 +17,7 @@ return [
'csrfParam'
=>
'_csrf-backend'
,
'csrfParam'
=>
'_csrf-backend'
,
],
],
'user'
=>
[
'user'
=>
[
'identityClass'
=>
'
common
\models\User'
,
'identityClass'
=>
'
backend
\models\User'
,
'enableAutoLogin'
=>
true
,
'enableAutoLogin'
=>
true
,
'identityCookie'
=>
[
'name'
=>
'_identity-backend'
,
'httpOnly'
=>
true
],
'identityCookie'
=>
[
'name'
=>
'_identity-backend'
,
'httpOnly'
=>
true
],
],
],
...
...
src/backend/controllers/ClassesController.php
View file @
339e7a1e
...
@@ -13,6 +13,7 @@ use common\libs\Utils;
...
@@ -13,6 +13,7 @@ use common\libs\Utils;
use
common\models\Classes
;
use
common\models\Classes
;
use
common\models\User
;
use
common\models\User
;
use
Yii
;
use
Yii
;
use
yii\filters\AccessControl
;
use
yii\web\Controller
;
use
yii\web\Controller
;
class
ClassesController
extends
Controller
class
ClassesController
extends
Controller
...
@@ -20,6 +21,24 @@ class ClassesController extends Controller
...
@@ -20,6 +21,24 @@ class ClassesController extends Controller
public
$layout
=
'back'
;
public
$layout
=
'back'
;
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
'rules'
=>
[
[
'allow'
=>
true
,
'roles'
=>
[
'@'
],
]
]
]
];
}
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$status
=
Yii
::
$app
->
request
->
get
(
'status'
,
Classes
::
STATUS_OK
);
$status
=
Yii
::
$app
->
request
->
get
(
'status'
,
Classes
::
STATUS_OK
);
...
...
src/backend/controllers/CourseController.php
View file @
339e7a1e
...
@@ -17,6 +17,7 @@ use common\models\TranscodeQueue;
...
@@ -17,6 +17,7 @@ use common\models\TranscodeQueue;
use
common\models\User
;
use
common\models\User
;
use
Yii
;
use
Yii
;
use
yii\base\ExitException
;
use
yii\base\ExitException
;
use
yii\filters\AccessControl
;
use
yii\web\Controller
;
use
yii\web\Controller
;
use
yii\web\NotFoundHttpException
;
use
yii\web\NotFoundHttpException
;
...
@@ -25,6 +26,24 @@ class CourseController extends Controller
...
@@ -25,6 +26,24 @@ class CourseController extends Controller
public
$layout
=
'back'
;
public
$layout
=
'back'
;
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
'rules'
=>
[
[
'allow'
=>
true
,
'roles'
=>
[
'@'
],
]
]
]
];
}
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$status
=
Yii
::
$app
->
request
->
get
(
'status'
,
Course
::
STATUS_OK
);
$status
=
Yii
::
$app
->
request
->
get
(
'status'
,
Course
::
STATUS_OK
);
...
@@ -54,7 +73,12 @@ class CourseController extends Controller
...
@@ -54,7 +73,12 @@ class CourseController extends Controller
$courseware
=
Courseware
::
findOne
([
'course_id'
=>
$course
->
id
]);
$courseware
=
Courseware
::
findOne
([
'course_id'
=>
$course
->
id
]);
$class
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
]);
$class
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
]);
return
$this
->
render
(
'detail'
,
compact
(
'course'
,
'courseware'
,
'class'
));
/* @var $qiniu \common\components\Qiniu */
$qiniu
=
\Yii
::
$app
->
qiniu
;
$previewUrl
=
$qiniu
->
getUrl
(
'public'
,
$course
->
preview_pic
);
$sourceUrl
=
$qiniu
->
getUrl
(
'video'
,
$courseware
->
name
);
return
$this
->
render
(
'detail'
,
compact
(
'course'
,
'courseware'
,
'class'
,
'previewUrl'
,
'sourceUrl'
));
}
}
/**
/**
...
...
src/backend/controllers/SiteController.php
View file @
339e7a1e
<?php
<?php
namespace
backend\controllers
;
namespace
backend\controllers
;
use
backend\models\LoginForm
;
use
backend\models\User
;
use
common\libs\Utils
;
use
Yii
;
use
Yii
;
use
yii\web\Controller
;
use
yii\web\Controller
;
use
yii\filters\AccessControl
;
use
yii\filters\AccessControl
;
use
common\models\LoginForm
;
/**
/**
* Site controller
* Site controller
*/
*/
class
SiteController
extends
Controller
class
SiteController
extends
Controller
{
{
public
$layout
=
'lte'
;
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
@@ -53,7 +58,7 @@ class SiteController extends Controller
...
@@ -53,7 +58,7 @@ class SiteController extends Controller
*/
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
return
$this
->
re
nder
(
'index'
);
return
$this
->
re
direct
([
'course/index'
]
);
}
}
/**
/**
...
@@ -63,6 +68,15 @@ class SiteController extends Controller
...
@@ -63,6 +68,15 @@ class SiteController extends Controller
*/
*/
public
function
actionLogin
()
public
function
actionLogin
()
{
{
//$user = new User();
//$user->username = 'admin';
//$user->password_hash = \Yii::$app->security->generatePasswordHash('111111');
//$user->ip = Utils::getRealIP();
//$user->logged_at = time();
//$user->save();
//
//print_r($user->errors);
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
return
$this
->
goHome
();
return
$this
->
goHome
();
}
}
...
@@ -85,7 +99,6 @@ class SiteController extends Controller
...
@@ -85,7 +99,6 @@ class SiteController extends Controller
public
function
actionLogout
()
public
function
actionLogout
()
{
{
Yii
::
$app
->
user
->
logout
();
Yii
::
$app
->
user
->
logout
();
return
$this
->
goHome
();
return
$this
->
goHome
();
}
}
}
}
src/backend/models/LoginForm.php
0 → 100644
View file @
339e7a1e
<?php
namespace
backend\models
;
use
common\libs\Utils
;
use
Yii
;
use
yii\base\Model
;
/**
* Login form
*/
class
LoginForm
extends
Model
{
const
MAX_LOGIN_NUM
=
5
;
const
LOGIN_CYCLE
=
900
;
//second
const
REDIS_KEY_PREFIX
=
'yy_adminlogin_ip'
;
public
$username
;
public
$password
;
public
$rememberMe
=
true
;
private
$_user
;
public
function
formName
()
{
return
''
;
}
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
// username and password are both required
[[
'username'
,
'password'
],
'required'
],
// password is validated by validatePassword()
[
'password'
,
'validatePassword'
],
[
'username'
,
'string'
]
];
}
/**
* @return array
*/
public
function
attributeLabels
()
{
return
[
'username'
=>
'用户名'
,
'password'
=>
'密码'
,
];
}
/**
* Validates the password.
* This method serves as the inline validation for password.
*
* @param string $attribute the attribute currently being validated
* @param array $params the additional name-value pairs given in the rule
*/
public
function
validatePassword
(
$attribute
,
$params
)
{
$redis
=
Yii
::
$app
->
redis
;
$key
=
self
::
REDIS_KEY_PREFIX
.
'::'
.
Utils
::
getRealIP
();
$value
=
$redis
->
get
(
$key
);
if
(
$value
===
NULL
)
{
$redis
->
setex
(
$key
,
self
::
LOGIN_CYCLE
,
self
::
MAX_LOGIN_NUM
);
}
else
{
if
(
$value
<=
0
)
{
$this
->
addError
(
'password'
,
'登陆已经被限制了.'
);
}
}
if
(
!
$this
->
hasErrors
())
{
$user
=
$this
->
getUser
();
if
(
!
$user
||
!
$user
->
validatePassword
(
$this
->
password
))
{
if
(
$value
!==
NULL
)
{
$redis
->
decr
(
$key
);
}
$this
->
addError
(
$attribute
,
'用户名或者密码错误'
);
}
}
}
/**
* Logs in a user using the provided username and password.
*
* @return boolean whether the user is logged in successfully
*/
public
function
login
()
{
if
(
$this
->
validate
())
{
return
Yii
::
$app
->
user
->
login
(
$this
->
getUser
(),
86400
*
7
);
}
else
{
return
false
;
}
}
/**
* Finds user by [[username]]
*
* @return User
*/
protected
function
getUser
()
{
if
(
$this
->
_user
===
NULL
)
{
$this
->
_user
=
User
::
findOne
([
'username'
=>
$this
->
username
]);
}
return
$this
->
_user
;
}
}
src/backend/models/User.php
0 → 100644
View file @
339e7a1e
<?php
namespace
backend\models
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\ActiveRecord
;
/**
* 后台管理用户类
*
* @property integer $id
* @property string $username
* @property string $auth_key
* @property string $password_hash
* @property integer $status
* @property string $ip
* @property string $created_at
* @property string $updated_at
* @property string $logged_at
*/
class
User
extends
ActiveRecord
implements
\yii\web\IdentityInterface
{
public
static
function
tableName
()
{
return
'{{%admin_users}}'
;
}
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
[
'class'
=>
TimestampBehavior
::
className
(),
'attributes'
=>
[
ActiveRecord
::
EVENT_BEFORE_INSERT
=>
[
'created_at'
,
'updated_at'
],
ActiveRecord
::
EVENT_BEFORE_UPDATE
=>
[
'updated_at'
],
]
]
];
}
public
function
rules
()
{
return
[
[[
'username'
,
'password_hash'
,
'ip'
,
'logged_at'
],
'required'
],
[[
'id'
,
'status'
],
'integer'
],
[[
'created_at'
,
'updated_at'
,
'logged_at'
],
'safe'
],
[[
'username'
,
'auth_key'
,
'ip'
],
'string'
,
'max'
=>
32
],
[[
'password_hash'
],
'string'
,
'max'
=>
255
],
[
'status'
,
'default'
,
'value'
=>
1
]
];
}
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getAuthKey
()
{
return
$this
->
auth_key
;
}
public
function
validateAuthKey
(
$authKey
)
{
return
$this
->
getAuthKey
()
==
$authKey
;
}
/**
* Validates password
*
* @param string $password password to validate
* @return boolean if password provided is valid for current user
*/
public
function
validatePassword
(
$password
)
{
return
\Yii
::
$app
->
security
->
validatePassword
(
$password
,
$this
->
password_hash
);
}
public
function
beforeSave
(
$insert
)
{
if
(
parent
::
beforeSave
(
$insert
))
{
if
(
$this
->
isNewRecord
)
{
$this
->
auth_key
=
\Yii
::
$app
->
security
->
generateRandomString
();
}
return
true
;
}
return
false
;
}
public
static
function
findIdentity
(
$id
)
{
return
self
::
findOne
([
'id'
=>
$id
]);
}
public
static
function
findIdentityByAccessToken
(
$token
,
$type
=
null
)
{
throw
new
\yii\base\NotSupportedException
(
'"findIdentityByAccessToken" is not implemented.'
);
}
}
\ No newline at end of file
src/backend/views/course/detail.php
0 → 100644
View file @
339e7a1e
<?php
/**
* @var $course \common\models\Course
*/
use
yii\helpers\Html
;
$this
->
title
=
$course
->
name
;
?>
<p>
<?=
$class
->
name
?>
</p>
<div><img
src=
"
<?=
$previewUrl
?>
-m.preview"
></div>
<div>
<?=
$course
->
intro
?>
</div>
<p>
[
<a
href=
"
<?=
$sourceUrl
?>
"
target=
"_blank"
>
下载源视频
</a>
]
</p>
\ No newline at end of file
src/backend/views/layouts/back.php
View file @
339e7a1e
...
@@ -4,17 +4,20 @@
...
@@ -4,17 +4,20 @@
* @var $content string
* @var $content string
*/
*/
use
backend\assets\LteAsset
;
use
backend\assets\LteAsset
;
use
yii\helpers\Url
;
$lte
=
$this
->
assetManager
->
getBundle
(
LteAsset
::
className
());
$lte
=
$this
->
assetManager
->
getBundle
(
LteAsset
::
className
());
//$bootstrap = $this->assetManager->getBundle('\yii\bootstrap\BootstrapAsset');
//$bootstrap = $this->assetManager->getBundle('\yii\bootstrap\BootstrapAsset');
//$this->registerJsFile($this->assetManager->getAssetUrl($bootstrap, 'js/bootstrap.min.js'));
$this
->
beginPage
();
$this
->
beginPage
();
$this
->
beginBody
();
$this
->
beginBody
();
//$this->registerJsFile($this->assetManager->getAssetUrl($bootstrap, 'js/bootstrap.min.js'));
$this
->
beginContent
(
'@app/views/layouts/lte.php'
);
$this
->
beginContent
(
'@app/views/layouts/lte.php'
);
?>
?>
<!-- Main Header -->
<body
class=
"hold-transition skin-blue sidebar-mini"
>
<header
class=
"main-header"
>
<div
class=
"wrapper"
>
<!-- Main Header -->
<header
class=
"main-header"
>
<!-- Logo -->
<!-- Logo -->
<a
href=
"/"
class=
"logo"
>
<a
href=
"/"
class=
"logo"
>
...
@@ -33,101 +36,6 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -33,101 +36,6 @@ $this->beginContent('@app/views/layouts/lte.php');
<!-- Navbar Right Menu -->
<!-- Navbar Right Menu -->
<div
class=
"navbar-custom-menu"
>
<div
class=
"navbar-custom-menu"
>
<ul
class=
"nav navbar-nav"
>
<ul
class=
"nav navbar-nav"
>
<!-- Messages: style can be found in dropdown.less-->
<li
class=
"dropdown messages-menu"
>
<!-- Menu toggle button -->
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<i
class=
"fa fa-envelope-o"
></i>
<span
class=
"label label-success"
>
4
</span>
</a>
<ul
class=
"dropdown-menu"
>
<li
class=
"header"
>
You have 4 messages
</li>
<li>
<!-- inner menu: contains the messages -->
<ul
class=
"menu"
>
<li>
<!-- start message -->
<a
href=
"#"
>
<div
class=
"pull-left"
>
<!-- User Image -->
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"img-circle"
alt=
"User Image"
>
</div>
<!-- Message title and timestamp -->
<h4>
Support Team
<small><i
class=
"fa fa-clock-o"
></i>
5 mins
</small>
</h4>
<!-- The message -->
<p>
Why not buy a new awesome theme?
</p>
</a>
</li>
<!-- end message -->
</ul>
<!-- /.menu -->
</li>
<li
class=
"footer"
><a
href=
"#"
>
See All Messages
</a></li>
</ul>
</li>
<!-- /.messages-menu -->
<!-- Notifications Menu -->
<li
class=
"dropdown notifications-menu"
>
<!-- Menu toggle button -->
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<i
class=
"fa fa-bell-o"
></i>
<span
class=
"label label-warning"
>
10
</span>
</a>
<ul
class=
"dropdown-menu"
>
<li
class=
"header"
>
You have 10 notifications
</li>
<li>
<!-- Inner Menu: contains the notifications -->
<ul
class=
"menu"
>
<li>
<!-- start notification -->
<a
href=
"#"
>
<i
class=
"fa fa-users text-aqua"
></i>
5 new members joined today
</a>
</li>
<!-- end notification -->
</ul>
</li>
<li
class=
"footer"
><a
href=
"#"
>
View all
</a></li>
</ul>
</li>
<!-- Tasks Menu -->
<li
class=
"dropdown tasks-menu"
>
<!-- Menu Toggle Button -->
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<i
class=
"fa fa-flag-o"
></i>
<span
class=
"label label-danger"
>
9
</span>
</a>
<ul
class=
"dropdown-menu"
>
<li
class=
"header"
>
You have 9 tasks
</li>
<li>
<!-- Inner menu: contains the tasks -->
<ul
class=
"menu"
>
<li>
<!-- Task item -->
<a
href=
"#"
>
<!-- Task title and progress text -->
<h3>
Design some buttons
<small
class=
"pull-right"
>
20%
</small>
</h3>
<!-- The progress bar -->
<div
class=
"progress xs"
>
<!-- Change the css width attribute to simulate progress -->
<div
class=
"progress-bar progress-bar-aqua"
style=
"width: 20%"
role=
"progressbar"
aria-valuenow=
"20"
aria-valuemin=
"0"
aria-valuemax=
"100"
>
<span
class=
"sr-only"
>
20% Complete
</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
</ul>
</li>
<li
class=
"footer"
>
<a
href=
"#"
>
View all tasks
</a>
</li>
</ul>
</li>
<!-- User Account Menu -->
<!-- User Account Menu -->
<li
class=
"dropdown user user-menu"
>
<li
class=
"dropdown user user-menu"
>
<!-- Menu Toggle Button -->
<!-- Menu Toggle Button -->
...
@@ -135,7 +43,7 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -135,7 +43,7 @@ $this->beginContent('@app/views/layouts/lte.php');
<!-- The user image in the navbar-->
<!-- The user image in the navbar-->
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"user-image"
alt=
"User Image"
>
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"user-image"
alt=
"User Image"
>
<!-- hidden-xs hides the username on small devices so only the image appears. -->
<!-- hidden-xs hides the username on small devices so only the image appears. -->
<span
class=
"hidden-xs"
>
Alexander Pierce
</span>
<span
class=
"hidden-xs"
>
<?=
\Yii
::
$app
->
user
->
getIdentity
()
->
username
?>
</span>
</a>
</a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
<!-- The user image in the menu -->
<!-- The user image in the menu -->
...
@@ -143,7 +51,7 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -143,7 +51,7 @@ $this->beginContent('@app/views/layouts/lte.php');
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"img-circle"
alt=
"User Image"
>
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"img-circle"
alt=
"User Image"
>
<p>
<p>
Alexander Pierce
- Web Developer
<?=
\Yii
::
$app
->
user
->
getIdentity
()
->
username
?>
- Web Developer
<small>
Member since Nov. 2012
</small>
<small>
Member since Nov. 2012
</small>
</p>
</p>
</li>
</li>
...
@@ -168,7 +76,7 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -168,7 +76,7 @@ $this->beginContent('@app/views/layouts/lte.php');
<a
href=
"#"
class=
"btn btn-default btn-flat"
>
Profile
</a>
<a
href=
"#"
class=
"btn btn-default btn-flat"
>
Profile
</a>
</div>
</div>
<div
class=
"pull-right"
>
<div
class=
"pull-right"
>
<a
href=
"#
"
class=
"btn btn-default btn-flat"
>
Sign out
</a>
<a
href=
"
<?=
Url
::
to
([
'site/logout'
])
?>
"
class=
"btn btn-default btn-flat"
>
Sign out
</a>
</div>
</div>
</li>
</li>
</ul>
</ul>
...
@@ -180,9 +88,9 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -180,9 +88,9 @@ $this->beginContent('@app/views/layouts/lte.php');
</ul>
</ul>
</div>
</div>
</nav>
</nav>
</header>
</header>
<!-- Left side column. contains the logo and sidebar -->
<!-- Left side column. contains the logo and sidebar -->
<aside
class=
"main-sidebar"
>
<aside
class=
"main-sidebar"
>
<!-- sidebar: style can be found in sidebar.less -->
<!-- sidebar: style can be found in sidebar.less -->
<section
class=
"sidebar"
>
<section
class=
"sidebar"
>
...
@@ -193,7 +101,7 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -193,7 +101,7 @@ $this->beginContent('@app/views/layouts/lte.php');
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"img-circle"
alt=
"User Image"
>
<img
src=
"
<?=
$this
->
assetManager
->
getAssetUrl
(
$lte
,
'img/user2-160x160.jpg'
)
?>
"
class=
"img-circle"
alt=
"User Image"
>
</div>
</div>
<div
class=
"pull-left info"
>
<div
class=
"pull-left info"
>
<p>
Alexander Pierce
</p>
<p>
<?=
\Yii
::
$app
->
user
->
getIdentity
()
->
username
?>
</p>
<!-- Status -->
<!-- Status -->
<a
href=
"#"
><i
class=
"fa fa-circle text-success"
></i>
Online
</a>
<a
href=
"#"
><i
class=
"fa fa-circle text-success"
></i>
Online
</a>
</div>
</div>
...
@@ -209,41 +117,43 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -209,41 +117,43 @@ $this->beginContent('@app/views/layouts/lte.php');
</span>
</span>
</div>
</div>
</form>
</form>
<!-- /.search form -->
<!-- Sidebar Menu -->
<!-- Sidebar Menu -->
<ul
class=
"sidebar-menu
"
>
<ul
class=
"sidebar-menu"
id=
"sidebarMenu"
data-route=
"
<?=
Yii
::
$app
->
controller
->
id
?>
"
>
<li
class=
"header"
>
基本
</li>
<li
class=
"header"
>
基本
</li>
<!-- Optionally, you can add icons to the links -->
<!-- Optionally, you can add icons to the links -->
<li><a
href=
"#"
><i
class=
"fa fa-link"
></i>
<span>
Link
</span></a></li>
<li><a
href=
"#"
><i
class=
"fa fa-link"
></i>
<span>
全局概揽
</span></a></li>
<li><a
href=
"#"
><i
class=
"fa fa-link"
></i>
<span>
Another Link
</span></a></li>
<li
class=
"header"
>
内容
</li>
<li
class=
"header"
>
内容
</li>
<li
><a
href=
"/classes"
><i
class=
"fa fa-link"
></i>
<span>
课堂管理
</span></a></li>
<li
class=
"RT_classes"
><a
href=
"/classes"
><i
class=
"fa fa-link"
></i>
<span>
课堂管理
</span></a></li>
<li
class=
"activ
e"
><a
href=
"/course"
><i
class=
"fa fa-link"
></i>
<span>
课程管理
</span></a></li>
<li
class=
"RT_cours
e"
><a
href=
"/course"
><i
class=
"fa fa-link"
></i>
<span>
课程管理
</span></a></li>
</ul>
</ul>
<!-- /.sidebar-menu -->
<script>
var
sidebar
=
$
(
"#sidebarMenu"
);
var
currentRoute
=
sidebar
.
data
(
"route"
);
sidebar
.
find
(
"li.RT_"
+
currentRoute
).
addClass
(
"active"
);
</script>
</section>
</section>
<!-- /.sidebar -->
<!-- /.sidebar -->
</aside>
</aside>
<!-- Content Wrapper. Contains page content -->
<!-- Content Wrapper. Contains page content -->
<div
class=
"content-wrapper"
>
<div
class=
"content-wrapper"
>
<?=
$content
?>
<?=
$content
?>
</div>
</div>
<!-- /.content-wrapper -->
<!-- /.content-wrapper -->
<!-- Main Footer -->
<!-- Main Footer -->
<footer
class=
"main-footer"
>
<footer
class=
"main-footer"
>
<!-- To the right -->
<!-- To the right -->
<div
class=
"pull-right hidden-xs"
>
<div
class=
"pull-right hidden-xs"
>
Anything you want
Anything you want
</div>
</div>
<!-- Default to the left -->
<!-- Default to the left -->
<strong>
Copyright
©
2016
<a
href=
"#"
>
Company
</a>
.
</strong>
All rights reserved.
<strong>
Copyright
©
2016
<a
href=
"#"
>
Company
</a>
.
</strong>
All rights reserved.
</footer>
</footer>
<!-- Control Sidebar -->
<!-- Control Sidebar -->
<aside
class=
"control-sidebar control-sidebar-dark"
>
<aside
class=
"control-sidebar control-sidebar-dark"
>
<!-- Create the tabs -->
<!-- Create the tabs -->
<ul
class=
"nav nav-tabs nav-justified control-sidebar-tabs"
>
<ul
class=
"nav nav-tabs nav-justified control-sidebar-tabs"
>
<li
class=
"active"
><a
href=
"#control-sidebar-home-tab"
data-toggle=
"tab"
><i
class=
"fa fa-home"
></i></a></li>
<li
class=
"active"
><a
href=
"#control-sidebar-home-tab"
data-toggle=
"tab"
><i
class=
"fa fa-home"
></i></a></li>
...
@@ -313,11 +223,14 @@ $this->beginContent('@app/views/layouts/lte.php');
...
@@ -313,11 +223,14 @@ $this->beginContent('@app/views/layouts/lte.php');
</div>
</div>
<!-- /.tab-pane -->
<!-- /.tab-pane -->
</div>
</div>
</aside>
</aside>
<!-- /.control-sidebar -->
<!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
immediately after the control sidebar -->
<div
class=
"control-sidebar-bg"
></div>
<div
class=
"control-sidebar-bg"
></div>
</div>
</body>
<?php
<?php
$this
->
endContent
();
$this
->
endContent
();
$this
->
endBody
();
$this
->
endBody
();
...
...
src/backend/views/layouts/lte.php
View file @
339e7a1e
...
@@ -24,12 +24,8 @@ AppAsset::register($this);
...
@@ -24,12 +24,8 @@ AppAsset::register($this);
<script src="http://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<script src="http://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<![endif]-->
</head>
</head>
<body
class=
"hold-transition skin-blue sidebar-mini"
>
<div
class=
"wrapper"
>
<?php
$this
->
beginBody
()
?>
<?php
$this
->
beginBody
()
?>
<?=
$content
?>
<?=
$content
?>
<?php
$this
->
endBody
()
?>
<?php
$this
->
endBody
()
?>
</div>
</body>
</html>
</html>
<?php
$this
->
endPage
()
?>
<?php
$this
->
endPage
()
?>
\ No newline at end of file
src/backend/views/site/login.php
View file @
339e7a1e
<?php
<?php
/**
/* @var $this yii\web\View */
* @var $this yii\web\View
/* @var $form yii\bootstrap\ActiveForm */
* @var $form yii\bootstrap\ActiveForm
/* @var $model \common\models\LoginForm */
* @var $model \backend\models\LoginForm
*/
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\bootstrap\ActiveForm
;
use
yii\bootstrap\ActiveForm
;
$this
->
title
=
'Login'
;
$this
->
title
=
'Login'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
//$this->params['breadcrumbs'][] = $this->title;
$usernameError
=
$model
->
getFirstError
(
'username'
);
$passwordError
=
$model
->
getFirstError
(
'password'
);
?>
?>
<div
class=
"site-login"
>
<h1>
<?=
Html
::
encode
(
$this
->
title
)
?>
</h1>
<p>
Please fill out the following fields to login:
</p>
<body
class=
"hold-transition login-page"
>
<div
class=
"login-box"
>
<div
class=
"login-logo"
><b>
Admin
</b>
YunYa
</div>
<!-- /.login-logo -->
<div
class=
"login-box-body"
>
<p
class=
"login-box-msg"
>
Sign in to start your session
</p>
<div
class=
"row"
>
<div
class=
"col-lg-5"
>
<?php
$form
=
ActiveForm
::
begin
([
'id'
=>
'login-form'
]);
?>
<?php
$form
=
ActiveForm
::
begin
([
'id'
=>
'login-form'
]);
?>
<div
class=
"form-group
<?php
if
(
$usernameError
)
{
?>
has-error
<?php
}
?>
"
>
<?=
$form
->
field
(
$model
,
'username'
)
->
textInput
([
'autofocus'
=>
true
])
?>
<?php
if
(
$usernameError
)
{
?>
<label
class=
"control-label"
for=
"inputError"
>
<?=
$form
->
field
(
$model
,
'password'
)
->
passwordInput
()
?>
<i
class=
"fa fa-times-circle-o"
></i>
<?=
$usernameError
?>
</label>
<?=
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
()
?>
<?php
}
?>
<input
type=
"text"
name=
"username"
class=
"form-control"
placeholder=
"Username"
value=
"
<?=
$model
->
username
?>
"
>
<div
class=
"form-group"
>
<span
class=
"glyphicon glyphicon-user form-control-feedback"
></span>
<?=
Html
::
submitButton
(
'Login'
,
[
'class'
=>
'btn btn-primary'
,
'name'
=>
'login-button'
])
?>
</div>
<div
class=
"form-group
<?php
if
(
$passwordError
)
{
?>
has-error
<?php
}
?>
"
>
<?php
if
(
$passwordError
)
{
?>
<label
class=
"control-label"
for=
"inputError"
>
<i
class=
"fa fa-times-circle-o"
></i>
<?=
$passwordError
?>
</label>
<?php
}
?>
<input
type=
"password"
name=
"password"
class=
"form-control"
placeholder=
"Password"
value=
"
<?=
$model
->
password
?>
"
>
<span
class=
"glyphicon glyphicon-lock form-control-feedback"
></span>
</div>
<div
class=
"row"
>
<div
class=
"col-xs-8"
></div>
<div
class=
"col-xs-4"
>
<?=
Html
::
submitButton
(
'Sign In'
,
[
'class'
=>
'btn btn-primary btn-block btn-flat'
,
'name'
=>
'login-button'
])
?>
</div>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/common/components/Qiniu.php
View file @
339e7a1e
...
@@ -136,7 +136,7 @@ class Qiniu extends Object
...
@@ -136,7 +136,7 @@ class Qiniu extends Object
$callbackUrl
=
YII_ENV
==
'dev'
$callbackUrl
=
YII_ENV
==
'dev'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
:
Url
::
to
([
'qiniu-callback/rem-upload'
],
true
);
:
\Yii
::
$app
->
params
[
'baseUrl'
]
.
Url
::
to
([
'qiniu-callback/rem-upload'
]
);
$policy
=
[
$policy
=
[
'returnBody'
=>
'{"key":$(key)}'
,
'returnBody'
=>
'{"key":$(key)}'
,
...
...
src/common/libs/QiniuTranscode.php
View file @
339e7a1e
...
@@ -53,20 +53,14 @@ class QiniuTranscode
...
@@ -53,20 +53,14 @@ class QiniuTranscode
$fops
=
self
::
transcodeFops
(
$avInfo
);
$fops
=
self
::
transcodeFops
(
$avInfo
);
$bucket
=
$qiniu
->
getStorageConfig
(
'video'
,
'bucket'
);
$bucket
=
$qiniu
->
getStorageConfig
(
'video'
,
'bucket'
);
$target
=
$bucket
.
':'
.
$targetKey
;
//存储位置
//存储位置
$target
=
$bucket
.
':'
.
$targetKey
;
$notifyUrl
=
YII_ENV
==
'dev'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
:
Url
::
to
([
'qiniu-callback/transcode'
],
true
);;
/* @var $err null|\Qiniu\Http\Error */
/* @var $err null|\Qiniu\Http\Error */
if
(
$fops
)
{
if
(
$fops
)
{
$fops
.=
'|saveas/'
.
\Qiniu\base64_urlSafeEncode
(
$target
);
$fops
.=
'|saveas/'
.
\Qiniu\base64_urlSafeEncode
(
$target
);
//发送处理请求
//发送处理请求
$persistent
=
new
PersistentFop
(
$auth
,
$bucket
,
null
,
$notifyUrl
);
$persistent
=
new
PersistentFop
(
$auth
,
$bucket
,
null
,
self
::
getNotifyUrl
()
);
list
(
$presistendId
,
$err
)
=
$persistent
->
execute
(
$sourceKey
,
$fops
);
list
(
$presistendId
,
$err
)
=
$persistent
->
execute
(
$sourceKey
,
$fops
);
if
(
$err
)
{
if
(
$err
)
{
...
@@ -124,17 +118,11 @@ class QiniuTranscode
...
@@ -124,17 +118,11 @@ class QiniuTranscode
//存储位置
//存储位置
$target
=
$bucket
.
':'
.
$targetKey
;
$target
=
$bucket
.
':'
.
$targetKey
;
$fops
=
$fops
.
'/ss/0/t/'
.
(
$freeTime
*
60
)
.
'|saveas/'
.
\Qiniu\base64_urlSafeEncode
(
$target
);
$fops
=
$fops
.
'/ss/0/t/'
.
(
$freeTime
*
60
)
.
'|saveas/'
.
\Qiniu\base64_urlSafeEncode
(
$target
);
$notifyUrl
=
YII_ENV
==
'dev'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
:
Url
::
to
([
'qiniu-callback/transcode'
],
true
);;
//发送处理请求
//发送处理请求
/* @var $err null|\Qiniu\Http\Error */
/* @var $err null|\Qiniu\Http\Error */
$persistent
=
new
PersistentFop
(
$auth
,
$bucket
,
null
,
$notifyUrl
);
$persistent
=
new
PersistentFop
(
$auth
,
$bucket
,
null
,
self
::
getNotifyUrl
()
);
list
(
$presistendId
,
$err
)
=
$persistent
->
execute
(
$standKey
,
$fops
);
list
(
$presistendId
,
$err
)
=
$persistent
->
execute
(
$standKey
,
$fops
);
if
(
$err
)
{
if
(
$err
)
{
...
@@ -176,10 +164,8 @@ class QiniuTranscode
...
@@ -176,10 +164,8 @@ class QiniuTranscode
$fopsAddon
.=
'/ar/'
.
$target
[
'ar'
];
$fopsAddon
.=
'/ar/'
.
$target
[
'ar'
];
}
}
//视频采样率对比
//视频采样率对比,七牛文档指出如果给出的码率大于原码率,则会使用原码率转换,但某些视频仍然会出现码率变大,所以此处加上判断
//if ($video['bit_rate'] > $target['vb']) {
$fopsAddon
.=
'/vb/'
.
(
$video
[
'bit_rate'
]
>
$target
[
'vb'
]
?
$target
[
'vb'
]
:
$video
[
'bit_rate'
]);
$fopsAddon
.=
'/vb/'
.
$target
[
'vb'
];
//}
//编码对比
//编码对比
if
(
$video
[
'codec_name'
]
!=
'h264'
)
{
if
(
$video
[
'codec_name'
]
!=
'h264'
)
{
...
@@ -214,4 +200,11 @@ class QiniuTranscode
...
@@ -214,4 +200,11 @@ class QiniuTranscode
return
$fops
;
return
$fops
;
}
}
protected
static
function
getNotifyUrl
()
{
return
YII_ENV
==
'dev'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
:
\Yii
::
$app
->
params
[
'baseUrl'
]
.
Url
::
to
([
'qiniu-callback/transcode'
]);
}
}
}
\ No newline at end of file
src/common/models/User.php
View file @
339e7a1e
...
@@ -186,7 +186,7 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -186,7 +186,7 @@ class User extends ActiveRecord implements IdentityInterface
public
static
function
getAvatarUrl
(
$avatar
,
$size
=
'm'
)
public
static
function
getAvatarUrl
(
$avatar
,
$size
=
'm'
)
{
{
if
(
!
$avatar
)
{
if
(
!
$avatar
)
{
return
\frontend\assets\AppAsset
::
getStaticUrl
(
'img/avatarMax.png'
);
return
\
Yii
::
$app
->
params
[
'baseUrl'
]
.
\
frontend\assets\AppAsset
::
getStaticUrl
(
'img/avatarMax.png'
);
}
}
$url
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$avatar
);
$url
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$avatar
);
...
...
src/environments/dev/common/config/params-local.php
View file @
339e7a1e
...
@@ -36,5 +36,6 @@ return [
...
@@ -36,5 +36,6 @@ return [
'mchid'
=>
'1399794002'
,
'mchid'
=>
'1399794002'
,
'key'
=>
'8934e7d15453e97507ef794cf7b0519d'
,
'key'
=>
'8934e7d15453e97507ef794cf7b0519d'
,
'appsecret'
=>
'7c18222c6ec31efa65d21606a629585d'
,
'appsecret'
=>
'7c18222c6ec31efa65d21606a629585d'
,
]
],
'baseUrl'
=>
'http://dev.zuiketang.com'
];
];
src/environments/prod/common/config/params-local.php
View file @
339e7a1e
...
@@ -36,5 +36,6 @@ return [
...
@@ -36,5 +36,6 @@ return [
'mchid'
=>
'1399794002'
,
'mchid'
=>
'1399794002'
,
'key'
=>
'8934e7d15453e97507ef794cf7b0519d'
,
'key'
=>
'8934e7d15453e97507ef794cf7b0519d'
,
'appsecret'
=>
'7c18222c6ec31efa65d21606a629585d'
,
'appsecret'
=>
'7c18222c6ec31efa65d21606a629585d'
,
]
],
'baseUrl'
=>
'http://c.pp.cc'
];
];
src/frontend/controllers/HomeController.php
View file @
339e7a1e
...
@@ -21,6 +21,7 @@ use yii\filters\AccessControl;
...
@@ -21,6 +21,7 @@ use yii\filters\AccessControl;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\web\ForbiddenHttpException
;
use
yii\web\ForbiddenHttpException
;
use
yii\web\HttpException
;
class
HomeController
extends
\yii\web\Controller
class
HomeController
extends
\yii\web\Controller
{
{
...
@@ -60,6 +61,7 @@ class HomeController extends \yii\web\Controller
...
@@ -60,6 +61,7 @@ class HomeController extends \yii\web\Controller
* 首页
* 首页
* @param $classId 课堂id
* @param $classId 课堂id
* @return string
* @return string
* @throws HttpException
*/
*/
public
function
actionIndex
(
$classId
)
public
function
actionIndex
(
$classId
)
{
{
...
@@ -71,7 +73,7 @@ class HomeController extends \yii\web\Controller
...
@@ -71,7 +73,7 @@ class HomeController extends \yii\web\Controller
'classInfo'
=>
$classInfo
'classInfo'
=>
$classInfo
]);
]);
}
else
{
}
else
{
throw
new
InvalidParamException
(
'参数错误
'
);
throw
new
HttpException
(
404
,
'页面不存在
'
);
}
}
}
}
...
@@ -82,7 +84,7 @@ class HomeController extends \yii\web\Controller
...
@@ -82,7 +84,7 @@ class HomeController extends \yii\web\Controller
* @param $classId
* @param $classId
* @param $page
* @param $page
* @param int $num
* @param int $num
* @throws
Forbidden
HttpException
* @throws HttpException
*/
*/
public
function
actionGetCourseLists
(
$classId
,
$page
,
$num
=
10
)
public
function
actionGetCourseLists
(
$classId
,
$page
,
$num
=
10
)
{
{
...
@@ -90,7 +92,7 @@ class HomeController extends \yii\web\Controller
...
@@ -90,7 +92,7 @@ class HomeController extends \yii\web\Controller
if
(
$page
>=
0
and
$num
>
0
)
{
if
(
$page
>=
0
and
$num
>
0
)
{
$result
=
Course
::
getCourseListsByClassId
(
$classId
,
$page
,
$num
);
$result
=
Course
::
getCourseListsByClassId
(
$classId
,
$page
,
$num
);
}
else
{
}
else
{
throw
new
InvalidParamException
(
'参数错误
'
);
throw
new
HttpException
(
404
,
'页面不存在
'
);
}
}
}
else
{
}
else
{
throw
new
ForbiddenHttpException
(
'非法请求'
);
throw
new
ForbiddenHttpException
(
'非法请求'
);
...
@@ -118,18 +120,19 @@ class HomeController extends \yii\web\Controller
...
@@ -118,18 +120,19 @@ class HomeController extends \yii\web\Controller
* 视频播放页面
* 视频播放页面
* @param $courseId
* @param $courseId
* @return string
* @return string
* @throws HttpException
*/
*/
public
function
actionVideo
(
$courseId
)
public
function
actionVideo
(
$courseId
)
{
{
$coursewareInfo
=
Courseware
::
findOne
([
'course_id'
=>
$courseId
,
'status'
=>
Courseware
::
STATUS_OK
]);
$coursewareInfo
=
Courseware
::
findOne
([
'course_id'
=>
$courseId
,
'status'
=>
Courseware
::
STATUS_OK
]);
$course
=
Course
::
findOne
([
'id'
=>
$courseId
]);
$course
=
Course
::
findOne
([
'id'
=>
$courseId
]);
if
(
$course
===
NULL
)
{
if
(
$course
===
NULL
and
$coursewareInfo
[
'status'
]
!=
Courseware
::
STATUS_OK
)
{
throw
new
InvalidParamException
(
'参数错误
'
);
throw
new
HttpException
(
404
,
'页面不存在
'
);
}
}
$teachers
=
$course
->
teachers
;
$teachers
=
$course
->
teachers
;
$userId
=
Yii
::
$app
->
user
->
id
;
$userId
=
Yii
::
$app
->
user
->
id
;
if
(
$coursewareInfo
===
NULL
)
{
if
(
$coursewareInfo
===
NULL
)
{
throw
new
InvalidParamException
(
'参数错误
'
);
throw
new
HttpException
(
404
,
'页面不存在
'
);
}
else
{
}
else
{
$coursewareInfo
=
$coursewareInfo
->
toArray
();
$coursewareInfo
=
$coursewareInfo
->
toArray
();
$coursewareInfo
[
'previewUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$course
->
preview_pic
);
$coursewareInfo
[
'previewUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$course
->
preview_pic
);
...
@@ -145,9 +148,9 @@ class HomeController extends \yii\web\Controller
...
@@ -145,9 +148,9 @@ class HomeController extends \yii\web\Controller
$order
=
Orders
::
findByUserIdAndCourseId
(
$userId
,
$courseId
);
$order
=
Orders
::
findByUserIdAndCourseId
(
$userId
,
$courseId
);
$coursewareInfo
[
'isShop'
]
=
(
$order
!==
NULL
and
$order
->
status
===
Orders
::
PAID
?
TRUE
:
FALSE
);
$coursewareInfo
[
'isShop'
]
=
(
$order
!==
NULL
and
$order
->
status
===
Orders
::
PAID
?
TRUE
:
FALSE
);
}
}
if
(
$coursewareInfo
[
'isShop'
])
{
if
(
$coursewareInfo
[
'isShop'
])
{
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'src_stand'
]);
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'src_stand'
]);
}
else
{
}
else
{
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'src_free'
]);
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'src_free'
]);
}
}
unset
(
$coursewareInfo
[
'src_stand'
]);
unset
(
$coursewareInfo
[
'src_stand'
]);
...
@@ -157,7 +160,7 @@ class HomeController extends \yii\web\Controller
...
@@ -157,7 +160,7 @@ class HomeController extends \yii\web\Controller
$coursewareInfo
[
'className'
]
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
])
->
name
;
$coursewareInfo
[
'className'
]
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
])
->
name
;
$coursewareInfo
[
'isMobile'
]
=
Yii
::
$app
->
deviceDetect
->
isMobile
();
$coursewareInfo
[
'isMobile'
]
=
Yii
::
$app
->
deviceDetect
->
isMobile
();
//处理讲师头像
//处理讲师头像
foreach
(
$coursewareInfo
[
'teachers'
]
as
$key
=>
$value
){
foreach
(
$coursewareInfo
[
'teachers'
]
as
$key
=>
$value
)
{
$coursewareInfo
[
'teachers'
][
$key
][
'avatar'
]
=
User
::
getAvatarUrl
(
$value
[
'avatar'
]);
$coursewareInfo
[
'teachers'
][
$key
][
'avatar'
]
=
User
::
getAvatarUrl
(
$value
[
'avatar'
]);
}
}
return
$this
->
render
(
'video'
,
[
return
$this
->
render
(
'video'
,
[
...
@@ -166,6 +169,58 @@ class HomeController extends \yii\web\Controller
...
@@ -166,6 +169,58 @@ class HomeController extends \yii\web\Controller
}
}
}
}
/**
* 预览页
*/
public
function
actionPreview
(
$courseId
)
{
$coursewareInfo
=
Courseware
::
findOne
([
'course_id'
=>
$courseId
,
'status'
=>
Courseware
::
STATUS_OK
]);
$course
=
Course
::
findOne
([
'id'
=>
$courseId
]);
if
(
$course
===
NULL
or
Yii
::
$app
->
user
->
id
!==
$coursewareInfo
[
'user_id'
])
{
throw
new
HttpException
(
404
,
'页面不存在'
);
}
$teachers
=
$course
->
teachers
;
$userId
=
Yii
::
$app
->
user
->
id
;
if
(
$coursewareInfo
===
NULL
)
{
throw
new
HttpException
(
404
,
'页面不存在'
);
}
else
{
$coursewareInfo
=
$coursewareInfo
->
toArray
();
$coursewareInfo
[
'previewUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$course
->
preview_pic
);
$coursewareInfo
[
'intro'
]
=
$course
->
intro
;
$coursewareInfo
[
'courseName'
]
=
$course
->
name
;
$coursewareInfo
[
'teachers'
]
=
ArrayHelper
::
toArray
(
$teachers
);
$coursewareInfo
[
'isGuest'
]
=
Yii
::
$app
->
user
->
isGuest
;
$coursewareInfo
[
'isSupport'
]
=
(
Support
::
findByUserIdAndCoursewareId
(
$userId
,
$coursewareInfo
[
'id'
])
===
NULL
?
FALSE
:
TRUE
);
$coursewareInfo
[
'isFavorite'
]
=
(
Favorite
::
findByUserIdAndCoursewareId
(
$userId
,
$coursewareInfo
[
'id'
])
===
NULL
?
FALSE
:
TRUE
);
$coursewareInfo
[
'isShop'
]
=
FALSE
;
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
$coursewareInfo
[
'userAvatar'
]
=
User
::
getAvatarUrl
(
Yii
::
$app
->
user
->
identity
->
avatar
);
$order
=
Orders
::
findByUserIdAndCourseId
(
$userId
,
$courseId
);
$coursewareInfo
[
'isShop'
]
=
(
$order
!==
NULL
and
$order
->
status
===
Orders
::
PAID
?
TRUE
:
FALSE
);
}
if
(
$coursewareInfo
[
'isShop'
])
{
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'src_stand'
]);
}
else
{
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'src_free'
]);
}
unset
(
$coursewareInfo
[
'src_stand'
]);
unset
(
$coursewareInfo
[
'src_free'
]);
$coursewareInfo
[
'price'
]
=
$course
->
price
;
$coursewareInfo
[
'classId'
]
=
$course
->
class_id
;
$coursewareInfo
[
'className'
]
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
])
->
name
;
$coursewareInfo
[
'isMobile'
]
=
Yii
::
$app
->
deviceDetect
->
isMobile
();
//处理讲师头像
foreach
(
$coursewareInfo
[
'teachers'
]
as
$key
=>
$value
)
{
$coursewareInfo
[
'teachers'
][
$key
][
'avatar'
]
=
User
::
getAvatarUrl
(
$value
[
'avatar'
]);
}
return
$this
->
render
(
'preview'
,
[
'coursewareInfo'
=>
$coursewareInfo
]);
}
}
/**
/**
* 获取评论列表
* 获取评论列表
* @param $coursewareId
* @param $coursewareId
...
...
src/frontend/controllers/QiniuCallbackController.php
View file @
339e7a1e
...
@@ -66,6 +66,8 @@ class QiniuCallbackController extends \yii\web\Controller
...
@@ -66,6 +66,8 @@ class QiniuCallbackController extends \yii\web\Controller
*/
*/
public
function
actionTranscode
()
public
function
actionTranscode
()
{
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$post
=
Yii
::
$app
->
request
->
getRawBody
();
$post
=
Yii
::
$app
->
request
->
getRawBody
();
$data
=
json_decode
(
$post
,
true
);
$data
=
json_decode
(
$post
,
true
);
...
...
src/frontend/views/home/preview.php
0 → 100644
View file @
339e7a1e
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/10/26
* Time: 下午5:55
*/
$this
->
title
=
"
{
$coursewareInfo
[
'courseName'
]
}
-
{
$coursewareInfo
[
'className'
]
}
"
;
\frontend\assets\AppAsset
::
addCss
(
$this
,
'@web/assets/css/main.css'
);
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/home_video.js'
);
\frontend\assets\AppAsset
::
addCss
(
$this
,
'@web/assets/css/home_video.css'
);
$coursewareInfo
[
'isPreview'
]
=
true
;
?>
<input
type=
"hidden"
id=
"courseware-info"
value=
"
<?=
\yii\helpers\Html
::
encode
(
json_encode
(
$coursewareInfo
))
?>
"
/>
<div
id=
"video-container"
>
<video-play
:courseware-info=
"coursewareInfo"
></video-play>
<video-intro
:courseware-info=
"coursewareInfo"
></video-intro>
</div>
<div
class=
"xs-show-bg"
></div>
<div
class=
"copyright"
>
© 2016 c.pp.cc 皖ICP备13046642号
</div>
<script
type=
'text/javascript'
>
$
(
function
()
{
modeldialog
=
$
(
'.modal-dialog'
);
winh
=
$
(
window
).
height
();
mth
=
(
winh
-
245
)
/
2
;
modeldialog
.
css
(
'margin-top'
,
mth
);
})
</script>
\ No newline at end of file
src/frontend/views/home/video.php
View file @
339e7a1e
...
@@ -34,9 +34,6 @@ $this->registerJs($js);
...
@@ -34,9 +34,6 @@ $this->registerJs($js);
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/home_video.js'
);
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/home_video.js'
);
\frontend\assets\AppAsset
::
addCss
(
$this
,
'@web/assets/css/home_video.css'
);
\frontend\assets\AppAsset
::
addCss
(
$this
,
'@web/assets/css/home_video.css'
);
?>
?>
<style>
</style>
<input
type=
"hidden"
id=
"courseware-info"
value=
"
<?=
\yii\helpers\Html
::
encode
(
json_encode
(
$coursewareInfo
))
?>
"
/>
<input
type=
"hidden"
id=
"courseware-info"
value=
"
<?=
\yii\helpers\Html
::
encode
(
json_encode
(
$coursewareInfo
))
?>
"
/>
<div
id=
"video-container"
>
<div
id=
"video-container"
>
<video-play
:courseware-info=
"coursewareInfo"
></video-play>
<video-play
:courseware-info=
"coursewareInfo"
></video-play>
...
...
src/frontend/views/my-course/index.php
View file @
339e7a1e
...
@@ -45,7 +45,6 @@ $qiniu = \Yii::$app->qiniu;
...
@@ -45,7 +45,6 @@ $qiniu = \Yii::$app->qiniu;
target=
"_blank"
>
<?=
$course
[
'name'
]
?>
</a></div>
target=
"_blank"
>
<?=
$course
[
'name'
]
?>
</a></div>
<?php
endif
;
?>
<?php
endif
;
?>
<div
class=
"teacher"
>
<div
class=
"teacher"
>
<?php
if
(
$course
[
'teachers'
])
{
?>
讲师:
<?=
join
(
', '
,
array_column
(
$course
[
'teachers'
],
'name'
))
?><?php
}
?>
<?php
if
(
$course
[
'teachers'
])
{
?>
讲师:
<?=
join
(
', '
,
array_column
(
$course
[
'teachers'
],
'name'
))
?><?php
}
?>
</div>
</div>
...
...
src/frontend/web/js/home/components/video-intro.vue
View file @
339e7a1e
...
@@ -38,7 +38,9 @@
...
@@ -38,7 +38,9 @@
<
img
:
src
=
"coursewareInfo.userAvatar"
>
<
img
:
src
=
"coursewareInfo.userAvatar"
>
<
/div
>
<
/div
>
<
button
@
click
=
"comment"
class
=
"btn btn-primary pull-right m-t-10 m-r-10"
>
发表评论
<
/button
>
<
button
v
-
if
=
"!coursewareInfo.isPreview"
@
click
=
"comment"
class
=
"btn btn-primary pull-right m-t-10 m-r-10"
>
发表评论
<
/button
>
<
button
v
-
else
=
"!coursewareInfo.isPreview"
class
=
"btn btn-primary pull-right m-t-10 m-r-10"
>
发表评论
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
src/frontend/web/js/home/components/video-play.vue
View file @
339e7a1e
...
@@ -2,13 +2,25 @@
...
@@ -2,13 +2,25 @@
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"cnt-tit"
>
<div
class=
"cnt-tit"
>
<h3>
{{
coursewareInfo
.
courseName
}}
</h3>
<h3>
{{
coursewareInfo
.
courseName
}}
</h3>
<div
class=
"tit-share hidden-xs bdsharebuttonbox"
>
<div
v-if=
"!coursewareInfo.isPreview"
class=
"tit-share hidden-xs bdsharebuttonbox"
>
<a
href=
"javascript:;"
class=
"wechat post-icons bds_weixin"
data-cmd=
"weixin"
title=
"分享到微信"
></a>
<a
href=
"javascript:;"
class=
"wechat post-icons bds_weixin"
data-cmd=
"weixin"
title=
"分享到微信"
></a>
<a
href=
"javascript:;"
class=
"weibo post-icons bds_tsina"
data-cmd=
"tsina"
title=
"分享到新浪微博"
></a>
<a
href=
"javascript:;"
class=
"weibo post-icons bds_tsina"
data-cmd=
"tsina"
title=
"分享到新浪微博"
></a>
<a
href=
"javascript:;"
class=
"qzone post-icons bds_qzone"
data-cmd=
"qzone"
title=
"分享到QQ空间"
></a>
<a
href=
"javascript:;"
class=
"qzone post-icons bds_qzone"
data-cmd=
"qzone"
title=
"分享到QQ空间"
></a>
</div>
</div>
<div
v-else
class=
"tit-share hidden-xs bdsharebuttonbox"
>
<a
href=
"javascript:;"
class=
"wechat post-icons bds_weixin"
data-cmd=
"weixin"
title=
"分享到微信"
></a>
<a
href=
"javascript:;"
class=
"weibo post-icons bds_tsina"
data-cmd=
"tsina"
title=
"分享到新浪微博"
></a>
<a
href=
"javascript:;"
class=
"qzone post-icons bds_qzone"
data-cmd=
"qzone"
title=
"分享到QQ空间"
></a>
</div>
</div>
<myvideo
v-if=
"!coursewareInfo.isPreview"
:preview-url=
"coursewareInfo.previewUrl"
:video-url=
"coursewareInfo.videoUrl"
></myvideo>
<div
v-else
class=
"video-main"
>
<div
class=
"video-empty"
style=
"height:500px; width: 100%; background-color: #444; color: #fff; text-align: center;"
>
<i
class=
"icon-clock"
></i>
<p>
课程审核中,审核通过后大家才可以看到您的课程
<br
/>
审核结果将以短信形式通知您
</p>
</div>
</div>
</div>
<myvideo
:preview-url=
"coursewareInfo.previewUrl"
:video-url=
"coursewareInfo.videoUrl"
></myvideo>
<div
class=
"video-detail-info"
>
<div
class=
"video-detail-info"
>
<div
v-for=
"(index,item) in coursewareInfo.teachers"
class=
"video-teacher"
>
<div
v-for=
"(index,item) in coursewareInfo.teachers"
class=
"video-teacher"
>
<a
data-toggle=
"modal"
data-target=
"
{{
{
'#teacherInfo'
+
index
}}
}
"><img
<a
data-toggle=
"modal"
data-target=
"
{{
{
'#teacherInfo'
+
index
}}
}
"><img
...
@@ -16,15 +28,25 @@
...
@@ -16,15 +28,25 @@
<p><a href="
javascript
:;
" data-toggle="
modal
" data-target="
#
myModal2
">{{item.name
}}
</a></p>
<p><a href="
javascript
:;
" data-toggle="
modal
" data-target="
#
myModal2
">{{item.name
}}
</a></p>
</div>
</div>
<div class="
video
-
sm
-
info
pull
-
right
">
<div class="
video
-
sm
-
info
pull
-
right
">
<p class="
mb
-
right
">
<p
v-if="
!
coursewareInfo
.
isPreview
"
class="
mb
-
right
">
<a href="
javascript
:;
"><i class="
icon
-
comment
-
empty
"></i>{{coursewareInfo.comment_count
}}
</a>
<a href="
javascript
:;
"><i class="
icon
-
comment
-
empty
"></i>{{coursewareInfo.comment_count
}}
</a>
<a @click="
favorite
" href="
javascript
:;
"><i
<a @click="
favorite
" href="
javascript
:;
"><i
:class="
{
'icon-fav-full'
:
coursewareInfo
.
isFavorite
,
'icon-fav-empty'
:
!
coursewareInfo
.
isFavorite
}
"></i>{{coursewareInfo.favorite_count
}}
</a>
:class="
{
'icon-fav-full'
:
coursewareInfo
.
isFavorite
,
'icon-fav-empty'
:
!
coursewareInfo
.
isFavorite
}
"></i>{{coursewareInfo.favorite_count
}}
</a>
<a @click="
support
" href="
javascript
:;
"><i
<a @click="
support
" href="
javascript
:;
"><i
:class="
{
'icon-zan-full'
:
coursewareInfo
.
isSupport
,
'icon-zan-empty'
:
!
coursewareInfo
.
isSupport
}
"></i>{{coursewareInfo.support_count
}}
</a>
:class="
{
'icon-zan-full'
:
coursewareInfo
.
isSupport
,
'icon-zan-empty'
:
!
coursewareInfo
.
isSupport
}
"></i>{{coursewareInfo.support_count
}}
</a>
</p>
</p>
<p v-else class="
mb
-
right
">
<a href="
javascript
:;
"><i class="
icon
-
comment
-
empty
"></i>{{coursewareInfo.comment_count
}}
</a>
<a href="
javascript
:;
"><i
:class="
{
'icon-fav-full'
:
coursewareInfo
.
isFavorite
,
'icon-fav-empty'
:
!
coursewareInfo
.
isFavorite
}
"></i>{{coursewareInfo.favorite_count
}}
</a>
<a href="
javascript
:;
"><i
:class="
{
'icon-zan-full'
:
coursewareInfo
.
isSupport
,
'icon-zan-empty'
:
!
coursewareInfo
.
isSupport
}
"></i>{{coursewareInfo.support_count
}}
</a>
</p>
<button v-if="
coursewareInfo
.
isPreview
" class="
btn
btn
-
danger
m
-
l
-
20
mb
-
left
">购买
¥{{coursewareInfo.price
}}
</button>
<template v-else>
<button v-if="
coursewareInfo
.
isGuest
" @click="
login
" class="
btn
btn
-
danger
m
-
l
-
20
mb
-
left
">购买
<button v-if="
coursewareInfo
.
isGuest
" @click="
login
" class="
btn
btn
-
danger
m
-
l
-
20
mb
-
left
">购买
¥{{coursewareInfo.price
}}
¥{{coursewareInfo.price
}}
</button>
</button>
...
@@ -46,8 +68,7 @@
...
@@ -46,8 +68,7 @@
</template>
</template>
</template>
</template>
</template>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
ui/html/index-play.html
View file @
339e7a1e
...
@@ -69,9 +69,6 @@
...
@@ -69,9 +69,6 @@
</div>
</div>
<!--视频介绍-->
<div
class=
"warp-box"
>
<div
class=
"warp-box"
>
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"video-description"
>
<div
class=
"video-description"
>
...
@@ -147,9 +144,10 @@
...
@@ -147,9 +144,10 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--视频介绍-->
<div
class=
"copyright"
>
© 2016 c.pp.cc 皖ICP备13046642号
</div>
<div
class=
"copyright"
>
© 2016 c.pp.cc 皖ICP备13046642号
</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