Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vmusicchart-cms
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phạm Văn Đoan
vmusicchart-cms
Commits
41c3e6b5
Commit
41c3e6b5
authored
Apr 23, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thêm chức năng cập nhật ảnh cho bài hát
parent
708d281c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
181 additions
and
5 deletions
+181
-5
CmsTrack.php
application/controllers/backend/CmsTrack.php
+92
-1
MyHelper.php
application/libraries/MyHelper.php
+6
-2
Report_views_monthly_model.php
application/models/Report_views_monthly_model.php
+0
-1
Track_model.php
application/models/Track_model.php
+13
-0
show_track_view.php
application/views/backend/cms_track/show_track_view.php
+4
-1
update_track_image_view.php
...ation/views/backend/cms_track/update_track_image_view.php
+66
-0
No files found.
application/controllers/backend/CmsTrack.php
View file @
41c3e6b5
...
@@ -250,7 +250,7 @@ class CmsTrack extends CI_Controller
...
@@ -250,7 +250,7 @@ class CmsTrack extends CI_Controller
$db_art_path
=
$upload_path
.
'/'
.
$upload_data
[
'file_name'
];
$db_art_path
=
$upload_path
.
'/'
.
$upload_data
[
'file_name'
];
}
}
$this
->
track_model
->
update
(
$insert_id
,
$title
,
$db_art_path
);
$this
->
track_model
->
update
(
$insert_id
,
$title
,
$db_art_path
);
$this
->
track_model
->
add_singer
(
$singer
,
$insert_id
);
$this
->
track_model
->
add_singer
(
$singer
,
$insert_id
);
$this
->
track_model
->
add_artist
(
$artist
,
$insert_id
);
$this
->
track_model
->
add_artist
(
$artist
,
$insert_id
);
}
}
//
//
...
@@ -382,6 +382,57 @@ class CmsTrack extends CI_Controller
...
@@ -382,6 +382,57 @@ class CmsTrack extends CI_Controller
}
}
}
}
public
function
updateTrackImage
(
$track_id
,
$call_back
=
null
)
{
// Thêm đoạn check sự tồn tại của bài hát
//
$this
->
_data
[
'track'
]
=
$contest
=
$this
->
track_model
->
getById
(
$track_id
);
$this
->
form_validation
->
set_rules
(
'track_image'
,
'Ảnh bài hát'
,
''
);
$this
->
form_validation
->
set_message
(
'required'
,
'<li class="list-unstyled">Bắt buộc nhập, chọn.</li>'
);
$this
->
form_validation
->
set_message
(
'is_unique'
,
'<li class="list-unstyled">Đã tồn tại.</li>'
);
// Xử lý form
if
(
$this
->
form_validation
->
run
(
$this
)
==
false
)
{
$this
->
_data
[
'track_image'
]
=
$this
->
input
->
post
(
'track_image'
);
//
$this
->
_data
[
'functionName'
]
=
'Cập nhật ảnh bài hát'
;
$this
->
_data
[
'action'
]
=
__FUNCTION__
;
$this
->
_data
[
'titlePage'
]
=
'Cập nhật ảnh bài hát'
;
$this
->
_data
[
'loadPage'
]
=
'backend/cms_track/update_track_image_view'
;
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
else
{
if
(
empty
(
$_FILES
[
'track_image'
][
'name'
]))
{
$this
->
session
->
set_flashdata
(
'error'
,
'Cập nhật ảnh bài hát không thành công'
);
redirect
(
base_url
(
'backend/cmsTrack/showTrack/'
.
$track_id
));
}
$update
=
$this
->
privateUpdateTrackArt
(
$track_id
,
'track_image'
,
true
);
if
(
$update
)
{
$this
->
session
->
set_flashdata
(
'success'
,
'Cập nhật ảnh bài hát thành công'
);
}
else
{
$this
->
session
->
set_flashdata
(
'error'
,
'Cập nhật ảnh bài hát không thành công'
);
}
// Ghi log
$this
->
actionlog_model
->
add
(
'UPDATED'
,
'Cập nhật ảnh cho bài hát.'
,
'Actionlog_model'
,
'tracks'
,
$track_id
);
// Nếu thêm ca sĩ từ trang home thì quay trở về trang home
if
(
$call_back
==
'home'
)
{
redirect
(
base_url
(
'backend/home/index'
));
}
redirect
(
base_url
(
'backend/cmsTrack/showTrack/'
.
$track_id
));
}
}
/**
/**
* Xem chi tiết bài hát
* Xem chi tiết bài hát
*
*
...
@@ -456,4 +507,43 @@ class CmsTrack extends CI_Controller
...
@@ -456,4 +507,43 @@ class CmsTrack extends CI_Controller
return
true
;
return
true
;
}
}
/**
* Hàm hỗ trợ upload file ảnh bài hát
*
* @param $track_id
* @param $track_image_field
* @param bool $is_same_src
* @return bool
*/
private
function
privateUpdateTrackArt
(
$track_id
,
$track_image_field
,
$is_same_src
=
false
)
{
// Xử lý upload: avatar
$db_art_path
=
''
;
$upload_path
=
'uploads/tracks/arts'
;
if
(
$is_same_src
)
{
$upload_full_path
=
$upload_path
;
}
else
{
$upload_full_path
=
'/home/aseanvn/public_html/vmusicchart.dcv.vn/'
.
$upload_path
;
}
$config
[
'upload_path'
]
=
$upload_full_path
;
$config
[
'file_name'
]
=
md5
(
$track_id
.
time
());
$config
[
'allowed_types'
]
=
'gif|jpg|png|jpeg'
;
$config
[
'max_size'
]
=
20480
;
$config
[
'max_width'
]
=
500
;
$config
[
'max_height'
]
=
500
;
$this
->
load
->
library
(
'upload'
,
$config
);
if
(
$this
->
upload
->
do_upload
(
$track_image_field
))
{
$upload_data
=
$this
->
upload
->
data
();
$db_art_path
=
$upload_path
.
'/'
.
$upload_data
[
'file_name'
];
$this
->
track_model
->
update_art
(
$track_id
,
$db_art_path
);
return
true
;
}
return
false
;
}
}
}
\ No newline at end of file
application/libraries/MyHelper.php
View file @
41c3e6b5
...
@@ -768,12 +768,16 @@ class MyHelper
...
@@ -768,12 +768,16 @@ class MyHelper
*
*
* @return string
* @return string
*/
*/
public
static
function
getArtByTrack
(
$art
)
public
static
function
getArtByTrack
(
$art
,
$is_same_src
=
false
)
{
{
$CI
=
&
get_instance
();
$CI
=
&
get_instance
();
$default_image
=
base_url
(
'images/track.png'
);
$default_image
=
base_url
(
'images/track.png'
);
if
(
$art
)
{
if
(
$art
)
{
$default_image
=
$CI
->
config
->
item
(
'vmusicchart_url'
)
.
str_replace
(
'%w'
,
200
,
$art
);
if
(
$is_same_src
)
{
$default_image
=
base_url
(
str_replace
(
'%w'
,
200
,
$art
));
}
else
{
$default_image
=
$CI
->
config
->
item
(
'vmusicchart_url'
)
.
str_replace
(
'%w'
,
200
,
$art
);
}
}
}
return
$default_image
;
return
$default_image
;
}
}
...
...
application/models/Report_views_monthly_model.php
View file @
41c3e6b5
...
@@ -46,7 +46,6 @@ class Report_views_monthly_model extends CI_Model
...
@@ -46,7 +46,6 @@ class Report_views_monthly_model extends CI_Model
public
function
selectSearch
()
public
function
selectSearch
()
{
{
error_log
(
'a:'
.
$this
->
_table
);
$this
->
db
->
select
(
'month, year'
);
$this
->
db
->
select
(
'month, year'
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
distinct
(
$this
->
_table
.
'.month'
);
$this
->
db
->
distinct
(
$this
->
_table
.
'.month'
);
...
...
application/models/Track_model.php
View file @
41c3e6b5
...
@@ -104,6 +104,19 @@ class Track_model extends CI_Model
...
@@ -104,6 +104,19 @@ class Track_model extends CI_Model
$this
->
db
->
update
(
$this
->
_table
);
$this
->
db
->
update
(
$this
->
_table
);
}
}
/**
* Chỉ cập nhật ảnh cho bài hát
*
* @param $id
* @param $art_path
*/
public
function
update_art
(
$id
,
$art_path
)
{
$this
->
db
->
set
(
'art'
,
$art_path
);
$this
->
db
->
where
(
'id'
,
$id
);
$this
->
db
->
update
(
$this
->
_table
);
}
public
function
update_track_artists
(
$id_track
,
$user_id
,
$id
,
$active
)
public
function
update_track_artists
(
$id_track
,
$user_id
,
$id
,
$active
)
{
{
// die($dataUpdate);
// die($dataUpdate);
...
...
application/views/backend/cms_track/show_track_view.php
View file @
41c3e6b5
...
@@ -29,6 +29,9 @@
...
@@ -29,6 +29,9 @@
<a
class=
"btn btn-sm btn-primary"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/addComposer/'
.
$track
[
0
][
'id'
]);
?>
"
>
<a
class=
"btn btn-sm btn-primary"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/addComposer/'
.
$track
[
0
][
'id'
]);
?>
"
>
<i
class=
"glyphicon-plus"
></i>
Cập nhật Nhạc sĩ
<i
class=
"glyphicon-plus"
></i>
Cập nhật Nhạc sĩ
</a>
</a>
<a
class=
"btn btn-sm btn-warning"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/updateTrackImage/'
.
$track
[
0
][
'id'
]
.
'/null'
);
?>
"
>
<i
class=
"glyphicon-plus"
></i>
Cập nhật ảnh bài hát
</a>
</div>
</div>
</div>
</div>
<br>
<br>
...
@@ -45,7 +48,7 @@
...
@@ -45,7 +48,7 @@
<div
class=
"profile-info-name"
>
Ảnh
</div>
<div
class=
"profile-info-name"
>
Ảnh
</div>
<div
class=
"profile-info-value"
>
<div
class=
"profile-info-value"
>
<span>
<span>
<img
src=
"
<?php
echo
MyHelper
::
getArtByTrack
(
$track
[
0
][
'art'
])
?>
"
<img
src=
"
<?php
echo
MyHelper
::
getArtByTrack
(
$track
[
0
][
'art'
]
,
false
)
?>
"
style=
"max-width: 200px; max-height: 200px"
>
style=
"max-width: 200px; max-height: 200px"
>
</span>
</span>
</div>
</div>
...
...
application/views/backend/cms_track/update_track_image_view.php
0 → 100644
View file @
41c3e6b5
<div
class=
"row"
>
<div
class=
"widget-box"
>
<div
class=
"widget-header"
>
<p
class=
"widget-title"
>
Cập nhật thông tin Ca sĩ
</p>
</div>
<div
class=
"widget-body"
>
<div
class=
"widget-main"
>
<?php
$url
=
'backend/cmsTrack/updateTrackImage/'
.
$track
[
0
][
'id'
]
.
'/null'
;
$attributes
=
array
(
'class'
=>
'form-horizontal'
,
'id'
=>
'myform'
);
echo
form_open_multipart
(
base_url
(
$url
),
$attributes
);
?>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
></label>
<div
class=
"col-lg-3"
>
<input
type=
"hidden"
name=
"id"
value=
"
<?php
echo
$track
[
0
][
'id'
];
?>
"
/>
<?php
if
(
validation_errors
()){
echo
form_error
(
'id'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Tên bài hát (*)
</label>
<div
class=
"col-lg-3"
>
<p>
<?php
echo
$track
[
0
][
'title'
];
?>
</p>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Ảnh hiện tại
</label>
<div
class=
"col-lg-3"
>
<img
src=
"
<?php
echo
MyHelper
::
getArtByTrack
(
$track
[
0
][
'art'
],
false
)
?>
"
style=
"max-width: 200px; max-height: 200px"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Ảnh mới
<br>
(kích thước tối đa
<span
class=
"color-red"
>
500x500px
</span>
)
</label>
<div
class=
"col-lg-3"
>
<input
type=
"file"
name=
"track_image"
>
<?php
if
(
validation_errors
()){
echo
form_error
(
'track_image'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-lg-3"
>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/showTrack/'
.
$track
[
0
][
'id'
]);
?>
"
onclick=
"return confirm('Bạn có chắc chắn muốn quay lại trang chi tiết không?')"
>
<button
type=
"button"
class=
"btn btn-sm btn-default"
>
<i
class=
"ace-icon fa fa-arrow-left"
></i>
Quay lại
</button>
</a>
</div>
<div
class=
"col-lg-4"
>
<button
class=
"btn btn-sm btn-primary"
type=
"submit"
name=
"btnSave"
>
<i
class=
"ace-icon fa fa-check bigger-110"
></i>
Lưu lại
</button>
</div>
</div>
<?php
echo
form_close
();
?>
</div>
</div>
</div>
</div>
<!-- /.row -->
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.chosen-select'
).
chosen
({
allow_single_deselect
:
true
,
no_results_text
:
"Không có kết quả cần tìm"
});
});
</script>
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