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
131399a0
Commit
131399a0
authored
Oct 13, 2016
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成申请课堂
定制表单
parent
e0009e36
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
174 deletions
+133
-174
Classes.php
src/common/models/Classes.php
+32
-10
ClassesInfoController.php
src/frontend/controllers/ClassesInfoController.php
+57
-0
CoursePublishForm.php
src/frontend/models/CoursePublishForm.php
+0
-92
apply.php
src/frontend/views/classes-info/apply.php
+35
-0
classCenter.php
src/frontend/views/layouts/classCenter.php
+1
-1
userCenter.php
src/frontend/views/layouts/userCenter.php
+8
-70
publish.php
src/frontend/views/my-course/publish.php
+0
-1
No files found.
src/common/models/Classes.php
View file @
131399a0
...
...
@@ -3,6 +3,8 @@
namespace
common\models
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\ActiveRecord
;
/**
* This is the model class for table "classes".
...
...
@@ -13,11 +15,12 @@ use Yii;
* @property string $id_name
* @property string $name
* @property string $intro
* @property string $desc
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
*/
class
Classes
extends
\yii\db\
ActiveRecord
class
Classes
extends
ActiveRecord
{
/**
* @inheritdoc
...
...
@@ -27,16 +30,36 @@ class Classes extends \yii\db\ActiveRecord
return
'classes'
;
}
/**
* @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
formName
()
{
return
''
;
}
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
[[
'user_id'
,
'id_number'
,
'id_name'
,
'name'
,
'intro'
,
'created_at'
,
'updated_at
'
],
'required'
],
[[
'user_id'
,
'status'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'intro'
],
'string'
],
[[
'
id_number'
,
'id_name'
,
'name'
],
'string'
,
'max'
=>
64
],
[[
'user_id'
,
'name'
,
'intro
'
],
'required'
],
[[
'user_id'
,
'status'
],
'integer'
],
[[
'intro'
,
'desc'
],
'string'
],
[[
'
name'
],
'string'
,
'max'
=>
30
],
];
}
...
...
@@ -50,11 +73,10 @@ class Classes extends \yii\db\ActiveRecord
'user_id'
=>
'User ID'
,
'id_number'
=>
'Id Number'
,
'id_name'
=>
'Id Name'
,
'name'
=>
'Name'
,
'intro'
=>
'Intro'
,
'status'
=>
'0 未审核 1 审核通过 2 审核不通过 3 锁定 '
,
'created_at'
=>
'Created At'
,
'updated_at'
=>
'Updated At'
,
'name'
=>
'课堂名称'
,
'intro'
=>
'课堂介绍'
,
'desc'
=>
'案例资源'
,
'status'
=>
'0 未审核 1 审核通过 2 审核不通过 3 锁定 '
];
}
}
src/frontend/controllers/ClassesInfoController.php
View file @
131399a0
...
...
@@ -2,11 +2,68 @@
namespace
frontend\controllers
;
use
common\models\Classes
;
use
Yii
;
use
yii\filters\AccessControl
;
class
ClassesInfoController
extends
\yii\web\Controller
{
public
$layout
=
'userCenter'
;
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
'rules'
=>
[
[
'allow'
=>
TRUE
,
'roles'
=>
[
'@'
],
]
],
]
];
}
public
function
actionIndex
()
{
return
$this
->
render
(
'index'
);
}
/**
* 申请课堂
*
* @return string|\yii\web\Response
*/
public
function
actionApply
()
{
$uid
=
Yii
::
$app
->
user
->
getId
();
$model
=
Classes
::
findOne
([
'user_id'
=>
$uid
]);
if
(
!
$model
)
{
$model
=
new
Classes
();
$agreement
=
0
;
}
else
{
$agreement
=
1
;
}
if
(
Yii
::
$app
->
request
->
getIsPost
())
{
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
user_id
=
Yii
::
$app
->
user
->
getId
();
$agreement
=
Yii
::
$app
->
request
->
post
(
'agreement'
);
if
(
!
$agreement
)
{
$model
->
addError
(
'agreement'
,
'必须同意使用协议'
);
}
elseif
(
$model
->
validate
()
&&
$model
->
save
())
{
return
$this
->
redirect
(
'/classes-info'
);
}
}
return
$this
->
render
(
'apply'
,
compact
(
'model'
,
'agreement'
));
}
}
src/frontend/models/CoursePublishForm.php
deleted
100644 → 0
View file @
e0009e36
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/9/28
* Time: 17:43
*/
namespace
frontend\models
;
use
common\models\CourseTeacher
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\ActiveRecord
;
use
yii\helpers\HtmlPurifier
;
class
CoursePublishForm
extends
ActiveRecord
{
public
$name
;
public
$teacher
;
public
$video
;
public
$price
;
public
$free_time
;
public
$intro
;
public
$preview
;
public
$recommend
;
public
$status
;
public
$create_at
;
public
$update_at
;
public
function
formName
()
{
return
""
;
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'name'
=>
'标题'
,
'avatar'
=>
'Avatar'
,
'intro'
=>
'Intro'
,
'created_at'
=>
'Created At'
,
'updated_at'
=>
'Updated At'
,
];
}
/**
* @inheritdoc
*/
public
function
beforeSave
(
$insert
)
{
if
(
!
parent
::
beforeSave
(
$insert
))
{
return
false
;
}
$this
->
intro
=
HtmlPurifier
::
process
(
$this
->
intro
);
return
true
;
}
public
function
rules
()
{
return
[
[[
'name'
,
'video'
,
'preview'
],
'required'
],
[
'name'
,
'string'
,
'length'
=>
[
1
,
60
]],
[
'teacher'
,
'exist'
,
'targetAttribute'
=>
'teacher_id'
,
'targetClass'
=>
CourseTeacher
::
className
(),
'allowArray'
=>
true
],
[
'prirce'
,
'integer'
,
'min'
=>
0
,
'max'
=>
9999
],
[
'free_time'
,
'integer'
,
'min'
=>
0
,
'max'
=>
15
],
[
'recommend'
,
'boolean'
],
[
'status'
,
'in'
,
'range'
=>
[
0
,
1
,
2
,
3
]]
];
}
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
[
'class'
=>
TimestampBehavior
::
className
(),
'attributes'
=>
[
ActiveRecord
::
EVENT_BEFORE_INSERT
=>
[
'created_at'
,
'updated_at'
],
ActiveRecord
::
EVENT_BEFORE_UPDATE
=>
[
'updated_at'
],
]
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
]
];
}
}
\ No newline at end of file
src/frontend/views/classes-info/apply.php
0 → 100644
View file @
131399a0
<?php
/**
* @var \common\models\Classes $model
* @var int $agreement
*/
use
frontend\models\MyActiveForm
;
use
yii\helpers\Html
;
$this
->
title
=
'申请课堂'
;
?>
<div
class=
"send-class apply-class-box"
>
<div
class=
"tit"
>
申请课堂
</div>
<?php
$form
=
MyActiveForm
::
begin
([
'id'
=>
'applyForm'
,
'options'
=>
[
'name'
=>
'applyClass'
]]);
?>
<?=
$form
->
field
(
$model
,
'name'
,
[
'inputOptions'
=>
[
'placeholder'
=>
'请输入课堂名称'
]])
?>
<?=
$form
->
field
(
$model
,
'intro'
)
->
textInput
([
'placeholder'
=>
'示例:面向谁?服务是什么?优势是什么?'
])
?>
<?=
$form
->
field
(
$model
,
'desc'
,
[
'template'
=>
"
{
label
}
\n
<div class=
\"
cls-intro-textarea
\"
>
{
input}</div>\n{hint}\n{error
}
"
])
->
textarea
([
'placeholder'
=>
'填写分享或培训的案例链接…'
])
?>
<div
class=
"cls-part"
>
<div
class=
"checkbox"
>
<label>
<?=
Html
::
checkbox
(
'agreement'
,
$agreement
==
1
)
?>
同意
<a
href=
"#"
>
云涯使用协议
</a>
及
<a
href=
"#"
>
版权声明
</a>
</label>
</div>
<?=
$model
->
getFirstError
(
'agreement'
)
?>
</div>
<div
class=
"btn-box text-center"
style=
"margin-top: 10px; "
>
<button
type=
"submit"
class=
"btn btn-save m-l-10"
>
保存
</button>
</div>
<?php
MyActiveForm
::
end
();
?>
</div>
src/frontend/views/layouts/classCenter.php
View file @
131399a0
...
...
@@ -26,7 +26,7 @@ $this->beginContent('@app/views/layouts/center.php');
<li>
<div
class=
"link"
><i
class=
"icon-ondemand_video"
></i>
我的课程
<i
class=
"icon-navigate_next"
></i></div>
<ul
class=
"submenu"
>
<li><a
href=
"
#
"
>
发布课程
</a></li>
<li><a
href=
"
/my-course/publish
"
>
发布课程
</a></li>
<li><a
href=
"#"
>
课程列表
</a></li>
</ul>
</li>
...
...
src/frontend/views/layouts/userCenter.php
View file @
131399a0
...
...
@@ -5,66 +5,12 @@ use frontend\assets\AppAsset;
/* @var $this \yii\web\View */
/* @var $content string */
$this
->
title
=
'基本本息'
;
AppAsset
::
register
(
$this
);
AppAsset
::
addCss
(
$this
,
'@web/assets/css/style.css'
);
$baseUrl
=
\yii\helpers\Url
::
base
();
//$assetsUrl = Yii::$app->assetManager->baseUrl.'/assets';
//
//$js = <<<JS
//var global = (function () {
// this.static_url = "$assetsUrl";
//})();
//JS;
//
//$this->registerJs($js, View::POS_HEAD);
$js
=
<<<JS
$(function() {
var Accordion = function(el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
// Variables privadas
var links = this.el.find(".link");
// Evento
links.on("click", {el: this.el, multiple: this.multiple}, this.dropdown)
};
Accordion.prototype.dropdown = function(e) {
var el = e.data.el, self = $(this), next = self.next();
next.slideToggle();
self.parent().toggleClass("open");
if (!e.data.multiple) {
el.find(".submenu").not(next).slideUp().parent().removeClass("open");
}
};
new Accordion($("#accordion"), false);
});
JS;
$this
->
registerJs
(
$js
,
View
::
POS_END
);
$this
->
beginPage
();
$this
->
beginBody
();
$this
->
beginContent
(
'@app/views/layouts/center.php'
);
?>
<?php
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
\Yii
::
$app
->
language
?>
"
>
<head>
<meta
charset=
"
<?=
Yii
::
$app
->
charset
?>
"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<title>
<?=
$this
->
title
?
Html
::
encode
(
$this
->
title
)
.
'-'
:
''
?>
最课堂
</title>
<?=
Html
::
csrfMetaTags
()
?>
<?php
$this
->
head
()
?>
</head>
<body>
<?php
$this
->
beginBody
();
?>
<?php
$this
->
beginContent
(
'@app/views/layouts/center.php'
);
?>
<div
class=
"tp-sidebar"
>
<div
class=
"logo"
><a
href=
"
<?=
\yii\helpers\Url
::
base
()
?>
"
><img
...
...
@@ -91,7 +37,7 @@ $this->registerJs($js, View::POS_END);
</ul>
<div
class=
"apply-class"
>
<button
class=
"btn btn-danger"
>
申请课堂
</button>
<button
class=
"btn btn-danger"
onclick=
"location.href='/classes-info/apply';"
>
申请课堂
</button>
</div>
</div>
...
...
@@ -104,15 +50,7 @@ $this->registerJs($js, View::POS_END);
</div>
</div>
</div>
<?php
$this
->
endContent
();
?>
<div
class=
"foot navbar-fixed-bottom"
>
<p><a
href=
"#"
>
隐私权政策
</a>
-
<a
href=
"#"
>
服务条款
</a>
-
<a
href=
"#"
>
地图条款
</a></p>
<p>
©2016 Zuiketang.com
</p>
</div>
<?php
$this
->
endBody
();
?>
</body>
</html>
<?php
$this
->
endPage
();
?>
<?php
$this
->
endContent
();
$this
->
endBody
();
$this
->
endPage
();
\ No newline at end of file
src/frontend/views/my-course/publish.php
View file @
131399a0
<?php
use
frontend\assets\AppAsset
;
use
yii\widgets\ActiveForm
;
/*
* @var $this yii\web\View
...
...
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