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
33d72d12
Commit
33d72d12
authored
Feb 19, 2016
by
Виталий Мурашко
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.task-on.com/ktask/task-on.com
parents
43352fa5
7ec50275
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
146 additions
and
40 deletions
+146
-40
backend/web/css/site.css
backend/web/css/site.css
+10
-1
common/modules/blog/models/Post.php
common/modules/blog/models/Post.php
+24
-1
common/modules/blog/views/post-admin/manage.php
common/modules/blog/views/post-admin/manage.php
+12
-0
common/modules/school/controllers/CoursesAdminController.php
common/modules/school/controllers/CoursesAdminController.php
+21
-13
common/modules/school/forms/CourseForm.php
common/modules/school/forms/CourseForm.php
+25
-21
common/modules/school/models/Courses.php
common/modules/school/models/Courses.php
+9
-1
common/modules/testings/controllers/TestController.php
common/modules/testings/controllers/TestController.php
+27
-3
console/migrations/m160219_112010_add_post_column.php
console/migrations/m160219_112010_add_post_column.php
+18
-0
No files found.
backend/web/css/site.css
View file @
33d72d12
...
@@ -121,3 +121,12 @@ a.desc:after {
...
@@ -121,3 +121,12 @@ a.desc:after {
margin-bottom
:
20px
;
margin-bottom
:
20px
;
}
}
.control-label
{
min-width
:
100px
;}
.control-label
{
min-width
:
100px
;}
.file-drop-zone
{
height
:
auto
;
}
.file-drop-zone-title
{
padding
:
35px
10px
;
}
.file-preview-image
{
height
:
100px
!important
;
}
\ No newline at end of file
common/modules/blog/models/Post.php
View file @
33d72d12
...
@@ -7,6 +7,7 @@ use Yii;
...
@@ -7,6 +7,7 @@ use Yii;
use
common\modules\languages\models\Languages
;
use
common\modules\languages\models\Languages
;
use
common\modules\blog\models\PostLang
;
use
common\modules\blog\models\PostLang
;
use
common\modules\blog\models\PostTag
;
use
common\modules\blog\models\PostTag
;
use
common\modules\users\models\User
;
use
common\models\MetaTags
;
use
common\models\MetaTags
;
/**
/**
...
@@ -52,7 +53,7 @@ class Post extends \common\components\ActiveRecordModel
...
@@ -52,7 +53,7 @@ class Post extends \common\components\ActiveRecordModel
{
{
return
[
return
[
[[
'url'
,
'active'
],
'required'
],
[[
'url'
,
'active'
],
'required'
],
[[
'active'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'active'
,
'created_at'
,
'updated_at'
,
'author_id'
],
'integer'
],
[[
'url'
],
'string'
,
'max'
=>
255
],
[[
'url'
],
'string'
,
'max'
=>
255
],
[[
'url'
],
'unique'
],
[[
'url'
],
'unique'
],
[[
'preview'
,
'unlinkFile'
,
'tags'
],
'safe'
],
[[
'preview'
,
'unlinkFile'
,
'tags'
],
'safe'
],
...
@@ -100,6 +101,7 @@ class Post extends \common\components\ActiveRecordModel
...
@@ -100,6 +101,7 @@ class Post extends \common\components\ActiveRecordModel
{
{
return
[
return
[
'id'
=>
'ID'
,
'id'
=>
'ID'
,
'author_id'
=>
'Автор'
,
'url'
=>
'Ссылка'
,
'url'
=>
'Ссылка'
,
'active'
=>
'Видимость'
,
'active'
=>
'Видимость'
,
'file'
=>
'Изображение'
,
'file'
=>
'Изображение'
,
...
@@ -173,10 +175,31 @@ class Post extends \common\components\ActiveRecordModel
...
@@ -173,10 +175,31 @@ class Post extends \common\components\ActiveRecordModel
return
$this
->
hasMany
(
PostTagAssign
::
className
(),
[
'post_id'
=>
'id'
]);
return
$this
->
hasMany
(
PostTagAssign
::
className
(),
[
'post_id'
=>
'id'
]);
}
}
/**
* @return \yii\db\ActiveQuery
*/
public
function
getAuthor
()
{
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'author_id'
]);
}
public
function
getThumbnailUrl
()
public
function
getThumbnailUrl
()
{
{
$path
=
pathinfo
(
$this
->
preview
);
$path
=
pathinfo
(
$this
->
preview
);
return
$path
[
'dirname'
]
.
'/'
.
$path
[
'filename'
]
.
'.thumb.'
.
$path
[
'extension'
];
return
$path
[
'dirname'
]
.
'/'
.
$path
[
'filename'
]
.
'.thumb.'
.
$path
[
'extension'
];
}
}
public
function
beforeSave
(
$insert
)
{
if
(
parent
::
beforeSave
(
$insert
))
{
$this
->
author_id
=
Yii
::
$app
->
user
->
identity
->
id
;
return
true
;
}
else
{
return
false
;
}
}
}
}
common/modules/blog/views/post-admin/manage.php
View file @
33d72d12
...
@@ -61,6 +61,18 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -61,6 +61,18 @@ $this->params['breadcrumbs'][] = $this->title;
return
null
;
return
null
;
}
}
],
],
[
'attribute'
=>
'author_id'
,
'value'
=>
function
(
$model
)
{
if
(
$model
->
author
)
{
return
$model
->
author
->
surname
.
' '
.
$model
->
author
->
name
;
}
return
null
;
}
],
[
[
'class'
=>
'common\components\ColorActionColumn'
,
'class'
=>
'common\components\ColorActionColumn'
,
...
...
common/modules/school/controllers/CoursesAdminController.php
View file @
33d72d12
...
@@ -62,6 +62,10 @@ class CoursesAdminController extends AdminController
...
@@ -62,6 +62,10 @@ class CoursesAdminController extends AdminController
];
];
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
()){
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
()){
if
(
$model
->
filename
)
{
$model
->
image
=
$model
->
filename
;
}
else
{
//Try to get file info
//Try to get file info
$model
->
upload_image
=
\yii\web\UploadedFile
::
getInstance
(
$model
,
'upload_image'
);
$model
->
upload_image
=
\yii\web\UploadedFile
::
getInstance
(
$model
,
'upload_image'
);
//If received, then I get the file name and asign it to $model->image in order to store it in db
//If received, then I get the file name and asign it to $model->image in order to store it in db
...
@@ -69,13 +73,17 @@ class CoursesAdminController extends AdminController
...
@@ -69,13 +73,17 @@ class CoursesAdminController extends AdminController
$image_name
=
$model
->
upload_image
->
name
;
$image_name
=
$model
->
upload_image
->
name
;
$model
->
image
=
$image_name
;
$model
->
image
=
$image_name
;
}
}
}
$model
->
save
();
$model
->
save
();
if
(
!
$model
->
filename
)
{
//If all went OK, then I proceed to save the image in filesystem
//If all went OK, then I proceed to save the image in filesystem
if
(
!
empty
(
$model
->
upload_image
)){
if
(
!
empty
(
$model
->
upload_image
)){
$model
->
upload_image
->
saveAs
(
$model
->
getPath
()
.
$image_name
);
$model
->
upload_image
->
saveAs
(
$model
->
getPath
()
.
$image_name
);
}
}
}
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
return
$this
->
redirect
([
'view'
,
'id'
=>
$model
->
id
]);
}
}
else
else
...
@@ -183,10 +191,10 @@ class CoursesAdminController extends AdminController
...
@@ -183,10 +191,10 @@ class CoursesAdminController extends AdminController
$paths
=
[];
$paths
=
[];
// get file names
// get file names
$filename
=
$images
[
'name'
][
"upload_image"
];
//
$filename = $images['name']["upload_image"];
// loop and process files
// loop and process files
$ext
=
explode
(
'.'
,
basename
(
$filename
));
//
$ext = explode('.', basename($filename));
$target
=
$model
->
getPath
()
.
md5
(
uniqid
())
.
"."
.
array_pop
(
$ext
);
$target
=
$model
->
getPath
()
.
$images
[
'name'
][
"upload_image"
];
//
md5(uniqid()) . "." . array_pop($ext);
if
(
move_uploaded_file
(
$images
[
'tmp_name'
][
"upload_image"
],
$target
))
{
if
(
move_uploaded_file
(
$images
[
'tmp_name'
][
"upload_image"
],
$target
))
{
$success
=
true
;
$success
=
true
;
$paths
[]
=
$target
;
$paths
[]
=
$target
;
...
...
common/modules/school/forms/CourseForm.php
View file @
33d72d12
...
@@ -7,29 +7,32 @@ use yii\helpers\Url;
...
@@ -7,29 +7,32 @@ use yii\helpers\Url;
use
common\modules\school\models\Courses
;
use
common\modules\school\models\Courses
;
use
common\modules\testings\models\Test
;
use
common\modules\testings\models\Test
;
$initialImages
=
''
;
if
(
$model
->
image
)
{
if
(
$model
->
image
)
{
$image
=
"<div class='file-widget'>"
.
FileInput
::
widget
([
$initialImages
[]
=
Html
::
img
(
$model
->
getUrl
(
$model
->
image
));
'model'
=>
$model
,
'attribute'
=>
'upload_image'
,
'language'
=>
'en'
,
'options'
=>
[
'multiple'
=>
false
,
'accept'
=>
'image/*'
],
'pluginOptions'
=>
[
/*'uploadUrl' => Url::to(['/school/courses-admin/upload']),*/
'showUpload'
=>
false
,
'initialPreview'
=>
[
Html
::
img
(
$model
->
getUrl
(
$model
->
image
))
],
'overwriteInitial'
=>
true
]
])
.
"</div>"
;
}
}
else
{
$image
=
"<div class='file-widget'>"
.
FileInput
::
widget
([
$image
=
"<div class='file-widget'>"
.
FileInput
::
widget
([
'model'
=>
$model
,
'model'
=>
$model
,
'attribute'
=>
'upload_image'
,
'attribute'
=>
'upload_image'
,
'language'
=>
'en'
,
'language'
=>
'en'
,
'options'
=>
[
'multiple'
=>
false
,
'accept'
=>
'image/*'
],
'options'
=>
[
'multiple'
=>
false
,
'accept'
=>
'image/*'
],
'pluginOptions'
=>
[
/*'uploadUrl' => Url::to(['/school/courses-admin/upload']),*/
'showUpload'
=>
false
,
'pluginOptions'
=>
[
'overwriteInitial'
=>
true
]
'uploadUrl'
=>
Url
::
to
([
'/school/courses-admin/upload'
]),
])
.
"</div>"
;
'showUpload'
=>
false
,
}
'overwriteInitial'
=>
true
,
'initialPreview'
=>
$initialImages
,
],
'pluginEvents'
=>
[
'fileuploaded'
=>
"function(event, data, previewId, index) {
$(
\"
[name='Courses[filename]']
\"
).val(data.files[0].name);
}"
,
'fileclear'
=>
"function(event) {
$(
\"
[name='Courses[filename]']
\"
).val();
}"
,
],
])
.
"</div>"
;
$elements
=
[
$elements
=
[
'test_id'
=>
[
'type'
=>
'dropdownlist'
,
'items'
=>
ArrayHelper
::
map
(
Test
::
find
()
->
all
(),
'id'
,
'name'
,
'session.name'
),
'empty'
=>
'Не задан'
],
'test_id'
=>
[
'type'
=>
'dropdownlist'
,
'items'
=>
ArrayHelper
::
map
(
Test
::
find
()
->
all
(),
'id'
,
'name'
,
'session.name'
),
'empty'
=>
'Не задан'
],
...
@@ -41,6 +44,7 @@ $elements = [
...
@@ -41,6 +44,7 @@ $elements = [
'items'
=>
Courses
::
$type_list
,
'items'
=>
Courses
::
$type_list
,
],
],
'spec_proposition'
=>
[
'type'
=>
'checkbox'
],
'spec_proposition'
=>
[
'type'
=>
'checkbox'
],
'filename'
=>
[
'type'
=>
'hidden'
],
'image'
=>
$image
,
'image'
=>
$image
,
];
];
...
...
common/modules/school/models/Courses.php
View file @
33d72d12
...
@@ -20,6 +20,8 @@ class Courses extends \common\components\ActiveRecordModel
...
@@ -20,6 +20,8 @@ class Courses extends \common\components\ActiveRecordModel
public
$upload_image
;
public
$upload_image
;
public
$filename
;
public
static
$type_list
=
[
public
static
$type_list
=
[
self
::
TYPE_IT
=>
'Для сотрудников it-отрасли'
,
self
::
TYPE_IT
=>
'Для сотрудников it-отрасли'
,
self
::
TYPE_IM
=>
'Для интернет-маркетологов'
,
self
::
TYPE_IM
=>
'Для интернет-маркетологов'
,
...
@@ -60,7 +62,7 @@ class Courses extends \common\components\ActiveRecordModel
...
@@ -60,7 +62,7 @@ class Courses extends \common\components\ActiveRecordModel
[[
'type'
,
'spec_proposition'
,
'test_id'
],
'integer'
],
[[
'type'
,
'spec_proposition'
,
'test_id'
],
'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'
,
'filename'
],
'safe'
],
[[
'upload_image'
],
'file'
,
'skipOnEmpty'
=>
true
,
'extensions'
=>
'png, jpg, jpeg, gif'
],
[[
'upload_image'
],
'file'
,
'skipOnEmpty'
=>
true
,
'extensions'
=>
'png, jpg, jpeg, gif'
],
];
];
}
}
...
@@ -88,6 +90,12 @@ class Courses extends \common\components\ActiveRecordModel
...
@@ -88,6 +90,12 @@ class Courses extends \common\components\ActiveRecordModel
}
}
}
}
public
function
afterFind
()
{
$this
->
filename
=
$this
->
image
;
parent
::
afterFind
();
}
public
function
getLessons
()
public
function
getLessons
()
{
{
return
$this
->
hasMany
(
Lessons
::
className
(),
[
'course_id'
=>
'id'
]);
return
$this
->
hasMany
(
Lessons
::
className
(),
[
'course_id'
=>
'id'
]);
...
...
common/modules/testings/controllers/TestController.php
View file @
33d72d12
...
@@ -146,10 +146,34 @@ class TestController extends \common\components\BaseController
...
@@ -146,10 +146,34 @@ class TestController extends \common\components\BaseController
public
function
actionGenPass
(
$id
)
public
function
actionGenPass
(
$id
)
{
{
$passing
=
$this
->
findModel
(
$id
);
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
$test
=
$this
->
findModel
(
$id
);
try
{
$passing
=
Passing
::
find
()
->
where
([
'user_id'
=>
Yii
::
$app
->
user
->
identity
->
id
,
'test_id'
=>
$id
])
->
one
();
if
(
!
$passing
)
{
$passing
=
new
Passing
;
$passing
->
user_id
=
Yii
::
$app
->
user
->
identity
->
id
;
$passing
->
test_id
=
$id
;
}
$transaction
->
commit
();
}
catch
(
\Exception
$e
)
{
$transaction
->
rollBack
();
throw
$e
;
}
$mg_gammas
=
array
();
$te_gammas
=
array
();
$user_id
=
Yii
::
app
()
->
request
->
cookies
[
self
::
AUTH_COOKIE
]
->
value
;
$user_id
=
Yii
::
app
()
->
request
->
cookies
[
self
::
AUTH_COOKIE
]
->
value
;
$cr3
=
new
CDbCriteria
;
$cr3
=
new
CDbCriteria
;
...
...
console/migrations/m160219_112010_add_post_column.php
0 → 100644
View file @
33d72d12
<?php
use
yii\db\Schema
;
use
yii\db\Migration
;
class
m160219_112010_add_post_column
extends
Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public
function
safeUp
()
{
$this
->
addColumn
(
'posts'
,
'author_id'
,
Schema
::
TYPE_INTEGER
.
'(11) NOT NULL AFTER `active`'
);
}
public
function
safeDown
()
{
$this
->
dropColumn
(
'posts'
,
'author_id'
);
}
}
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