mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Add a bookmark feature
This commit is contained in:
parent
b683c74846
commit
dacdced062
15 changed files with 762 additions and 0 deletions
55
plugin/Bookmark/Bookmark.php
Normal file
55
plugin/Bookmark/Bookmark.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
global $global;
|
||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/Bookmark/Objects/BookmarkTable.php';
|
||||
|
||||
class Bookmark extends PluginAbstract {
|
||||
|
||||
public function getDescription() {
|
||||
return "Save all insert, update and delete queries for audit";
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return "Bookmark";
|
||||
}
|
||||
|
||||
public function getUUID() {
|
||||
return "27570956-dc62-46e3-ace9-86c6e8f9c84b";
|
||||
}
|
||||
|
||||
public function getPluginMenu(){
|
||||
global $global;
|
||||
$filename = $global['systemRootPath'] . 'plugin/Bookmark/pluginMenu.html';
|
||||
return file_get_contents($filename);
|
||||
}
|
||||
|
||||
|
||||
public function getHeadCode() {
|
||||
if(empty($_GET['videoName'])){
|
||||
return false;
|
||||
}
|
||||
global $global;
|
||||
$css = '<link href="' .getCDN() . 'plugin/AD_Server/videojs-markers/videojs.markers.css" rel="stylesheet" type="text/css"/>';
|
||||
return $css;
|
||||
}
|
||||
|
||||
public function getFooterCode() {
|
||||
if(empty($_GET['videoName'])){
|
||||
return false;
|
||||
}
|
||||
global $global;
|
||||
$video = Video::getVideoFromCleanTitle($_GET['videoName']);
|
||||
$rows = BookmarkTable::getAllFromVideo($video['id']);
|
||||
include $global['systemRootPath'] . 'plugin/Bookmark/footer.php';
|
||||
}
|
||||
|
||||
public function getVideosManagerListButton() {
|
||||
global $global;
|
||||
|
||||
$btn = '';
|
||||
$btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block " onclick="avideoModalIframeFull(webSiteRootURL+\\\'plugin/Bookmark/editorVideo.php?videos_id=\'+ row.id +\'\\\');" ><i class="fas fa-bookmark"></i> Add Bookmarks</button>';
|
||||
return $btn;
|
||||
}
|
||||
|
||||
}
|
BIN
plugin/Bookmark/Objects/Bookmark.mwb
Normal file
BIN
plugin/Bookmark/Objects/Bookmark.mwb
Normal file
Binary file not shown.
BIN
plugin/Bookmark/Objects/Bookmark.mwb.bak
Normal file
BIN
plugin/Bookmark/Objects/Bookmark.mwb.bak
Normal file
Binary file not shown.
117
plugin/Bookmark/Objects/BookmarkTable.php
Normal file
117
plugin/Bookmark/Objects/BookmarkTable.php
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
||||
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||
|
||||
class BookmarkTable extends ObjectYPT {
|
||||
|
||||
protected $id, $timeInSeconds, $name, $videos_id;
|
||||
|
||||
static function getSearchFieldsNames() {
|
||||
return array('name','title');
|
||||
}
|
||||
|
||||
static function getTableName() {
|
||||
return 'bookmarks';
|
||||
}
|
||||
|
||||
function getTimeInSeconds() {
|
||||
return $this->timeInSeconds;
|
||||
}
|
||||
|
||||
function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function getVideos_id() {
|
||||
return $this->videos_id;
|
||||
}
|
||||
|
||||
function setTimeInSeconds($timeInSeconds) {
|
||||
$this->timeInSeconds = $timeInSeconds;
|
||||
}
|
||||
|
||||
function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
function setVideos_id($videos_id) {
|
||||
$this->videos_id = $videos_id;
|
||||
}
|
||||
|
||||
static function deleteAllFromVideo($videos_id) {
|
||||
global $global;
|
||||
if (!empty($videos_id)) {
|
||||
$sql = "DELETE FROM " . static::getTableName() . " ";
|
||||
$sql .= " WHERE videos_id = ?";
|
||||
$global['lastQuery'] = $sql;
|
||||
//_error_log("Delete Query: ".$sql);
|
||||
return sqlDAL::writeSql($sql,"i",array($videos_id));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static function getAllFromVideo($videos_id) {
|
||||
global $global;
|
||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE videos_id = ? ";
|
||||
$sql .= self::getSqlFromPost();
|
||||
$res = sqlDAL::readSql($sql,"i",array($videos_id));
|
||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||
sqlDAL::close($res);
|
||||
$rows = array();
|
||||
if ($res!=false) {
|
||||
foreach ($fullData as $row) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
} else {
|
||||
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
static function getAll() {
|
||||
global $global;
|
||||
$sql = "SELECT b.*, title, filename FROM " . static::getTableName() . " b LEFT JOIN videos v on v.id = videos_id WHERE 1=1 ";
|
||||
|
||||
$sql .= self::getSqlFromPost();
|
||||
$res = sqlDAL::readSql($sql);
|
||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||
sqlDAL::close($res);
|
||||
$rows = array();
|
||||
if ($res!=false) {
|
||||
foreach ($fullData as $row) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
} else {
|
||||
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
// make sure that will be only one bookmark for each time
|
||||
$row = self::getFromTime($this->getVideos_id(), $this->getTimeInSeconds());
|
||||
if(!empty($row)){
|
||||
$this->id = $row['id'];
|
||||
}
|
||||
parent::save();
|
||||
}
|
||||
|
||||
static protected function getFromTime($videos_id, $timeInSeconds) {
|
||||
global $global;
|
||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE videos_id = ? AND timeInSeconds = ? LIMIT 1";
|
||||
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
||||
$res = sqlDAL::readSql($sql,"ii",array($videos_id, $timeInSeconds));
|
||||
$data = sqlDAL::fetchAssoc($res);
|
||||
sqlDAL::close($res);
|
||||
if ($res) {
|
||||
$row = $data;
|
||||
} else {
|
||||
$row = false;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
235
plugin/Bookmark/editorVideo.php
Normal file
235
plugin/Bookmark/editorVideo.php
Normal file
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
require_once '../../videos/configuration.php';
|
||||
if (!User::isAdmin()) {
|
||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager plugin Audit"));
|
||||
exit;
|
||||
}
|
||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||
|
||||
$defaultBookmarkTime = 3;
|
||||
|
||||
$video = Video::getVideo($_GET['videos_id'], "", true);
|
||||
$poster = Video::getPathToFile("{$video['filename']}.jpg");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $_SESSION['language']; ?>">
|
||||
<head>
|
||||
<?php
|
||||
echo getHTMLTitle( __("Bookmark Editor"));
|
||||
?>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/head.php';
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo getCDN(); ?>view/css/DataTables/datatables.min.css"/>
|
||||
<link href="<?php echo getURL('node_modules/video.js/dist/video-js.min.css'); ?>" rel="stylesheet" type="text/css"/>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body class="<?php echo $global['bodyClass']; ?>">
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/navbar.php';
|
||||
?>
|
||||
<div class="container">
|
||||
|
||||
<?php
|
||||
require_once $global['systemRootPath'] . 'view/include/video.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<label for="currentTime"><?php echo __("Current Time"); ?>:</label>
|
||||
<input class="form-control" type="text" id="currentTime">
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<label for="subtitle"><?php echo __("Text"); ?>:</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="<?php echo __("Text"); ?>" id="subtitle">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-default" id="addBookmarkButton"><?php echo __("Add"); ?></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="list-group" id="bookmarksList">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/footer.php';
|
||||
?>
|
||||
<script src="<?php echo getURL('node_modules/video.js/dist/video.min.js'); ?>" type="text/javascript"></script>
|
||||
<?php
|
||||
$videoJSArray = array(
|
||||
"view/js/videojs-persistvolume/videojs.persistvolume.js",
|
||||
"view/js/BootstrapMenu.min.js");
|
||||
$jsURL = combineFiles($videoJSArray, "js");
|
||||
?>
|
||||
<script src="<?php echo $jsURL; ?>" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="<?php echo getCDN(); ?>view/css/DataTables/datatables.min.js"></script>
|
||||
<script>
|
||||
var bookmarksArray = [];
|
||||
var allBookmarksArray = [];
|
||||
var indexEditing = -1;
|
||||
function secondsToTime(sec) {
|
||||
var rest = parseInt((sec % 1) * 100);
|
||||
var date = new Date(null);
|
||||
date.setSeconds(sec); // specify value for SECONDS here
|
||||
var timeString = date.toISOString().substr(11, 8);
|
||||
return (timeString + '.' + rest);
|
||||
}
|
||||
|
||||
function timeToSeconds(hms) {
|
||||
var a = hms.split(':'); // split it at the colons
|
||||
// minutes are worth 60 seconds. Hours are worth 60 minutes.
|
||||
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
|
||||
return (seconds);
|
||||
}
|
||||
|
||||
function getTimeIndex(time) {
|
||||
for (var i = 0; i < bookmarksArray.length; i++) {
|
||||
if (bookmarksArray[i].start <= time && bookmarksArray[i].end >= time) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setTime(time) {
|
||||
$('#currentTime').val(secondsToTime(time));
|
||||
|
||||
}
|
||||
|
||||
function setPosition(time) {
|
||||
player.pause();
|
||||
player.currentTime(time);
|
||||
setTime(time);
|
||||
}
|
||||
|
||||
function addBookmark() {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Bookmark/page/bookmarkSave.json.php',
|
||||
data: {"videos_id": <?php echo $_GET['videos_id'] ?>, "timeInSeconds": timeToSeconds($('#currentTime').val()), "name": $('#subtitle').val()},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
loadBookmark();
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createList() {
|
||||
$("#bookmarksList").empty();
|
||||
|
||||
bookmarksArray.sort(function (a, b) {
|
||||
return b.timeInSeconds - a.timeInSeconds;
|
||||
});
|
||||
|
||||
for (i = bookmarksArray.length; i > 0; i--) {
|
||||
var index = i - 1;
|
||||
$("#bookmarksList").append('<div class="list-group-item list-group-item-action subtitleItem" bookmarkId="' + bookmarksArray[index].id + '" index="' + index + '" id="subtitleItem' + index + '">' +
|
||||
'<small class=\'text-muted\'>' + secondsToTime(bookmarksArray[index].timeInSeconds) + "</small> - " + bookmarksArray[i - 1].name +
|
||||
'<button class=\'btn btn-danger pull-right deleteBookmark btn-sm btn-xs\'><i class=\'fa fa-trash\'></i></button>' +
|
||||
'<button class=\'btn btn-primary pull-right editBookmark btn-sm btn-xs\'><i class=\'fa fa-edit\'></i></button>' +
|
||||
'</div>');
|
||||
}
|
||||
|
||||
$('.editBookmark').click(function () {
|
||||
var li = $(this).closest('div');
|
||||
var index = $(li).attr('index');
|
||||
$('.subtitleItem').removeClass('active');
|
||||
$('#subtitleItem' + index).addClass('active');
|
||||
setPosition(bookmarksArray[index].timeInSeconds);
|
||||
$('#subtitle').val(bookmarksArray[index].name);
|
||||
indexEditing = index;
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.deleteBookmark').click(function () {
|
||||
modal.showPleaseWait();
|
||||
var li = $(this).closest('div');
|
||||
var index = $(li).attr('index');
|
||||
var id = $(li).attr('bookmarkId');
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Bookmark/page/bookmarkDelete.json.php',
|
||||
data: {"id": id},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
loadBookmark();
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function loadBookmark() {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Bookmark/getBookmarks.json.php?videos_id=<?php echo $_GET['videos_id'] ?>',
|
||||
success: function (response) {
|
||||
allBookmarksArray = response;
|
||||
bookmarksArray = (allBookmarksArray.rows);
|
||||
createList();
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
loadBookmark();
|
||||
|
||||
$('#addBookmarkButton').click(function () {
|
||||
addBookmark();
|
||||
});
|
||||
|
||||
$('#currentTime').change(function () {
|
||||
setPosition(timeToSeconds($('#currentTime').val()));
|
||||
});
|
||||
$('#subtitle').keydown(function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
addBookmark();
|
||||
} else if ($('#subtitle').val() != '') {
|
||||
player.pause();
|
||||
} else {
|
||||
playerPlay(0);
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof player === 'undefined' && $('#mainVideo').length) {
|
||||
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
|
||||
}
|
||||
player.on('timeupdate', function () {
|
||||
setTime(this.currentTime());
|
||||
});
|
||||
|
||||
setInterval(function () {
|
||||
if (!player.paused()) {
|
||||
var index = getTimeIndex(player.currentTime());
|
||||
$('.subtitleItem').removeClass('active');
|
||||
$('#subtitleItem' + index).addClass('active');
|
||||
if (typeof bookmarksArray[index] !== 'undefined') {
|
||||
$('#subtitle').val(bookmarksArray[index].name);
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
30
plugin/Bookmark/footer.php
Normal file
30
plugin/Bookmark/footer.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<script src="<?php echo getCDN() ?>plugin/AD_Server/videojs-markers/videojs-markers.js" type="text/javascript"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
if (typeof player == 'undefined') {
|
||||
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
|
||||
}
|
||||
player.markers({
|
||||
markerStyle: {
|
||||
'width': '10px',
|
||||
'background-color': 'yellow'
|
||||
},
|
||||
markerTip: {
|
||||
display: true,
|
||||
text: function (marker) {
|
||||
return marker.text;
|
||||
}
|
||||
},
|
||||
markers: [
|
||||
<?php
|
||||
foreach ($rows as $value) {
|
||||
?>
|
||||
{time: <?php echo $value['timeInSeconds']; ?>, text: "<?php echo addcslashes($value['name'], '"'); ?>"},
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
20
plugin/Bookmark/getBookmarks.json.php
Normal file
20
plugin/Bookmark/getBookmarks.json.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
if(empty($_GET['videos_id'])){
|
||||
die(json_encode($obj));
|
||||
}
|
||||
require_once '../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'].'objects/video.php';
|
||||
require_once $global['systemRootPath'].'plugin/Bookmark/Objects/BookmarkTable.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$video = new Video("", "", $_GET['videos_id']);
|
||||
$videos_id = $video->getId();
|
||||
if(!empty($videos_id)){
|
||||
$obj->rows = BookmarkTable::getAllFromVideo($videos_id);
|
||||
$obj->error = false;
|
||||
}
|
||||
|
||||
die(json_encode($obj));
|
17
plugin/Bookmark/install/install.sql
Normal file
17
plugin/Bookmark/install/install.sql
Normal file
|
@ -0,0 +1,17 @@
|
|||
-- MySQL Workbench Forward Engineering
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `bookmarks` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`timeInSeconds` INT NOT NULL,
|
||||
`name` VARCHAR(255) NULL,
|
||||
`created` DATETIME NULL,
|
||||
`modified` DATETIME NULL,
|
||||
`videos_id` INT NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_bookmarks_videos_idx` (`videos_id` ASC),
|
||||
CONSTRAINT `fk_bookmarks_videos`
|
||||
FOREIGN KEY (`videos_id`)
|
||||
REFERENCES `videos` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE)
|
||||
ENGINE = InnoDB;
|
24
plugin/Bookmark/page/bookmarkDelete.json.php
Normal file
24
plugin/Bookmark/page/bookmarkDelete.json.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
require_once '../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/Bookmark/Objects/BookmarkTable.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
$obj->msg = "";
|
||||
|
||||
if(!User::isAdmin() && !Video::canEdit($_POST['videos_id'])){
|
||||
$obj->msg = "You cant do this";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
if(empty($_POST['id'])){
|
||||
$obj->msg = "ID can not be empty";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
$id = intval($_POST['id']);
|
||||
$row = new BookmarkTable($id);
|
||||
$obj->error = !$row->delete();
|
||||
die(json_encode($obj));
|
||||
?>
|
25
plugin/Bookmark/page/bookmarkSave.json.php
Normal file
25
plugin/Bookmark/page/bookmarkSave.json.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
//header('Content-Type: application/json');
|
||||
require_once '../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/Bookmark/Objects/BookmarkTable.php';
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
$obj->msg = "";
|
||||
|
||||
if(!User::isAdmin() && !Video::canEdit($_POST['videos_id'])){
|
||||
$obj->msg = "You cant do this";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
$o = new BookmarkTable(@$_POST['id']);
|
||||
$o->setName($_POST['name']);
|
||||
$o->setTimeInSeconds($_POST['timeInSeconds']);
|
||||
$o->setVideos_id($_POST['videos_id']);
|
||||
|
||||
if($id = $o->save()){
|
||||
$obj->error = false;
|
||||
}
|
||||
|
||||
|
||||
echo json_encode($obj);
|
18
plugin/Bookmark/page/bookmarks.json.php
Normal file
18
plugin/Bookmark/page/bookmarks.json.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
require_once '../../../videos/configuration.php';
|
||||
if (!User::isAdmin()) {
|
||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager plugin Audit"));
|
||||
exit;
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
require_once $global['systemRootPath'] . 'plugin/Bookmark/Objects/BookmarkTable.php';
|
||||
|
||||
$rows = BookmarkTable::getAll();
|
||||
$rowsTotal = BookmarkTable::getTotal();
|
||||
?>
|
||||
{
|
||||
"draw": <?php echo $_GET['draw']; ?>,
|
||||
"recordsTotal": <?php echo $rowsTotal; ?>,
|
||||
"recordsFiltered": <?php echo $rowsTotal; ?>,
|
||||
"data": <?php echo json_encode($rows); ?>
|
||||
}
|
49
plugin/Bookmark/page/editor.php
Normal file
49
plugin/Bookmark/page/editor.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
require_once '../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'objects/user.php';
|
||||
if (!User::isAdmin()) {
|
||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager plugin Audit"));
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $_SESSION['language']; ?>">
|
||||
<head>
|
||||
<?php
|
||||
echo getHTMLTitle( __("Bookmarks"));
|
||||
?>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/head.php';
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo getCDN(); ?>view/css/DataTables/datatables.min.css"/>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body class="<?php echo $global['bodyClass']; ?>">
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/navbar.php';
|
||||
?>
|
||||
<div class="container">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
include './editorForm.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
include './editorTable.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/footer.php';
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo getCDN(); ?>view/css/DataTables/datatables.min.js"></script>
|
||||
</body>
|
||||
</html>
|
92
plugin/Bookmark/page/editorForm.php
Normal file
92
plugin/Bookmark/page/editorForm.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<form id="bookmarkForm">
|
||||
<input type="hidden" id="inputId" name="id" >
|
||||
<input id="videos_id" name="videos_id" type="hidden">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<img id="inputVideo-poster" src="<?php echo $global['webSiteRootURL']; ?>img/notfound.jpg" class="ui-state-default img-responsive" alt="">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<input id="inputVideo" placeholder="<?php echo __("Video"); ?>" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputBookmark">Bookmark</label>
|
||||
<input id="inputBookmark" placeholder="<?php echo __("Bookmark"); ?>" class="form-control" name='name'>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputTime">Time in Sec.</label>
|
||||
<input type="number" step="1" class="form-control" id="inputTime" name="timeInSeconds" placeholder="Bookmark Time" >
|
||||
</div>
|
||||
<hr>
|
||||
<div class="col-md-4">
|
||||
<button class="btn btn-primary btn-block" onclick="clearBookmarkForm();return false;"><i class="fa fa-file"></i> Clear</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-success btn-block"><i class="fa fa-save"></i> Save</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-success btn-block" onclick="$('#inputId').val('');"><i class="fa fa-save"></i> Save as</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
var bookmarkTable;
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#bookmarkForm').submit(function (evt) {
|
||||
evt.preventDefault();
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Bookmark/page/bookmarkSave.json.php',
|
||||
data: $('#bookmarkForm').serializeArray(),
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
modal.hidePleaseWait();
|
||||
if (!response.error) {
|
||||
avideoAlert("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your plan has been saved!"); ?>", "success");
|
||||
} else {
|
||||
avideoAlert("<?php echo __("Your plan could not be saved!"); ?>", response.error, "error");
|
||||
}
|
||||
bookmarkTable.ajax.reload();
|
||||
clearBookmarkForm();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#inputVideo").autocomplete({
|
||||
minLength: 0,
|
||||
source: function (req, res) {
|
||||
$.ajax({
|
||||
url: webSiteRootURL+'videos.json',
|
||||
type: "POST",
|
||||
data: {
|
||||
searchPhrase: req.term,
|
||||
current: 1,
|
||||
rowCount: 10
|
||||
},
|
||||
success: function (data) {
|
||||
res(data.rows);
|
||||
}
|
||||
});
|
||||
},
|
||||
focus: function (event, ui) {
|
||||
$("#inputVideo").val(ui.item.title);
|
||||
return false;
|
||||
},
|
||||
select: function (event, ui) {
|
||||
$("#inputVideo").val(ui.item.title);
|
||||
$("#inputVideo-poster").attr("src", ui.item.videosURL.jpg_thumbsV2.url);
|
||||
$('#videos_id').val(ui.item.id);
|
||||
return false;
|
||||
}
|
||||
}).autocomplete("instance")._renderItem = function (ul, item) {
|
||||
return $("<li>").append("<div>" + item.title + "<br><?php echo __("Uploaded By"); ?>: " + item.user + "</div>").appendTo(ul);
|
||||
};
|
||||
});
|
||||
|
||||
function clearBookmarkForm() {
|
||||
$('#bookmarkForm')[0].reset();
|
||||
$('#inputVideo-poster').attr('src','<?php echo $global['webSiteRootURL']; ?>img/notfound.jpg');
|
||||
}
|
||||
</script>
|
77
plugin/Bookmark/page/editorTable.php
Normal file
77
plugin/Bookmark/page/editorTable.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
|
||||
<table id="bookmarkTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bookmark</th>
|
||||
<th>Time in Sec.</th>
|
||||
<th>Video ID</th>
|
||||
<th>Video Title</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Bookmark</th>
|
||||
<th>Time in Sec.</th>
|
||||
<th>Video ID</th>
|
||||
<th>Video Title</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
bookmarkTable = $('#bookmarkTable').DataTable({
|
||||
"processing": true,
|
||||
"serverSide": true,
|
||||
"ajax": {
|
||||
"url": "<?php echo $global['webSiteRootURL']; ?>plugin/Bookmark/page/bookmarks.json.php",
|
||||
},
|
||||
"columns": [
|
||||
{"data": "name"},
|
||||
{"data": "timeInSeconds"},
|
||||
{"data": "videos_id"},
|
||||
{"data": "title"},
|
||||
{"data": null, "defaultContent": "<button class='btn btn-sm btn-xs btn-primary editPlan'><i class='fa fa-edit'></i></button><button class='btn btn-sm btn-xs btn-danger deletePlan'><i class='fa fa-trash'></i></button>"}
|
||||
],
|
||||
select: true,
|
||||
//"order": [[5, "desc"]]
|
||||
});
|
||||
|
||||
|
||||
$('#bookmarkTable tbody').on('click', 'button.deletePlan', function () {
|
||||
var data = bookmarkTable.row($(this).parents('tr')).data();
|
||||
console.log("Delete");
|
||||
console.log(data);
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Bookmark/page/bookmarkDelete.json.php',
|
||||
data: {'id': data.id},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
modal.hidePleaseWait();
|
||||
if (!response.error) {
|
||||
avideoAlert("<?php echo __("Congratulations!"); ?>", "<?php echo __("Item deleted!"); ?>", "success");
|
||||
} else {
|
||||
avideoAlert("<?php echo __("Item could not be deleted!"); ?>", response.msg, "error");
|
||||
}
|
||||
bookmarkTable.ajax.reload();
|
||||
clearBookmarkForm();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#bookmarkTable tbody').on('click', 'button.editPlan', function () {
|
||||
var data = bookmarkTable.row($(this).parents('tr')).data();
|
||||
console.log(data);
|
||||
clearBookmarkForm();
|
||||
$('#inputId').val(data.id);
|
||||
$('#inputBookmark').val(data.name);
|
||||
$('#videos_id').val(data.videos_id);
|
||||
$('#inputVideo').val(data.title);
|
||||
$('#inputTime').val(data.timeInSeconds);
|
||||
$('#inputVideo-poster').attr('src','<?php echo $global['webSiteRootURL']; ?>videos/'+data.filename+'.jpg');
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
3
plugin/Bookmark/pluginMenu.html
Normal file
3
plugin/Bookmark/pluginMenu.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<button onclick="avideoModalIframe(webSiteRootURL +'plugin/Bookmark/page/editor.php');" class="btn btn-primary btn-sm btn-xs btn-block">
|
||||
<i class="fa fa-edit"></i> Edit
|
||||
</button>
|
Loading…
Add table
Add a link
Reference in a new issue