diff --git a/api/src/handlers/Video.php b/api/src/handlers/Video.php
index 4d2ecfe..9b37724 100755
--- a/api/src/handlers/Video.php
+++ b/api/src/handlers/Video.php
@@ -95,7 +95,10 @@ class Video extends RequestBase {
*/
private function loadVideos() {
$this->addActionHandler("loadVideo", function () {
- $query = "SELECT movie_name,movie_id,movie_url,thumbnail,poster,likes,quality,length FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
+ $video_id = $_POST['movieid'];
+
+ $query = " SELECT movie_name,movie_id,movie_url,thumbnail,poster,likes,quality,length
+ FROM videos WHERE movie_id=$video_id";
$result = $this->conn->query($query);
$row = $result->fetch_assoc();
@@ -112,7 +115,7 @@ class Video extends RequestBase {
// todo drop video url from db -- maybe one with and one without extension
// extension hardcoded here!!!
$arr["movie_url"] = str_replace("?", "%3F", $this->videopath . $row["movie_name"] . ".mp4");
- $arr["likes"] = $row["likes"];
+ $arr["likes"] = (int) $row["likes"];
$arr["quality"] = $row["quality"];
$arr["length"] = $row["length"];
@@ -120,13 +123,27 @@ class Video extends RequestBase {
$arr['tags'] = array();
$query = "SELECT t.tag_name FROM video_tags
INNER JOIN tags t on video_tags.tag_id = t.tag_id
- WHERE video_tags.video_id=" . $_POST['movieid'] . "
+ WHERE video_tags.video_id=$video_id
GROUP BY t.tag_name";
$result = $this->conn->query($query);
while ($r = mysqli_fetch_assoc($result)) {
array_push($arr['tags'], $r);
}
+ // get the random predict tags
+ $arr['suggesttag'] = array();
+ // select 5 random tags which are not selected for current video
+ $query = "SELECT * FROM tags
+ WHERE tag_id NOT IN (
+ SELECT video_tags.tag_id FROM video_tags
+ WHERE video_id=$video_id)
+ ORDER BY rand()
+ LIMIT 5";
+ $result = $this->conn->query($query);
+ while ($r = mysqli_fetch_assoc($result)) {
+ array_push($arr['suggesttag'], $r);
+ }
+
$this->commitMessage(json_encode($arr));
});
diff --git a/src/elements/Tag/Tag.js b/src/elements/Tag/Tag.js
index 45e5f43..21c73ce 100644
--- a/src/elements/Tag/Tag.js
+++ b/src/elements/Tag/Tag.js
@@ -18,6 +18,11 @@ class Tag extends React.Component {
* click handling for a Tag
*/
TagClick() {
+ if (this.props.onclick) {
+ this.props.onclick();
+ return;
+ }
+
const tag = this.props.children.toString().toLowerCase();
// call callback functin to switch to category page with specified tag
diff --git a/src/elements/Tag/Tag.test.js b/src/elements/Tag/Tag.test.js
index f53bfbc..7d9ec59 100644
--- a/src/elements/Tag/Tag.test.js
+++ b/src/elements/Tag/Tag.test.js
@@ -31,4 +31,17 @@ describe('