1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 02:39:46 +02:00

Allow also create actions menu

also users can now customize the action menu links on their videos
This commit is contained in:
DanielnetoDotCom 2021-06-02 14:12:47 -03:00
parent 2c2638c172
commit 48c6e8ca2c
9 changed files with 344 additions and 8 deletions

View file

@ -5,8 +5,9 @@ require_once $configFile;
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php'; require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php'; require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php';
$menu = Menu::getAllActive(2); $menu = Menu::getAllActive(Menu::$typeLeftMenu);
?> ?>
<!-- left menu start -->
<?php <?php
foreach ($menu as $key => $value) { foreach ($menu as $key => $value) {
?> ?>
@ -42,5 +43,5 @@ foreach ($menu as $key => $value) {
<?php <?php
} }
} }
?> ?>
<!-- left menu end -->

View file

@ -6,8 +6,9 @@ require_once $configFile;
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php'; require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php'; require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php';
$menu = Menu::getAllActive(1); $menu = Menu::getAllActive(Menu::$typeTopMenu);
?> ?>
<!-- right menu start -->
<?php <?php
foreach ($menu as $key => $value) { foreach ($menu as $key => $value) {
?> ?>
@ -52,4 +53,4 @@ foreach ($menu as $key => $value) {
<?php <?php
} }
?> ?>
<!-- right menu start -->

View file

@ -5,6 +5,17 @@ require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
require_once dirname(__FILE__) . '/../../../objects/user.php'; require_once dirname(__FILE__) . '/../../../objects/user.php';
class Menu extends ObjectYPT { class Menu extends ObjectYPT {
static $typeLeftMenu = 1;
static $typeTopMenu = 2;
static $typeActionMenu = 3;
static $typeActionMenuCustomURL = 4;
static $typeName = array(
1=>'Left',
2=>'Top',
3=>'Action',
4=>'Action Custom URL Per Video');
protected $id, $menuName, $categories_id, $users_groups_id, $menu_order, $status, $position, $type, $icon, $menuSeoUrl; protected $id, $menuName, $categories_id, $users_groups_id, $menu_order, $status, $position, $type, $icon, $menuSeoUrl;

View file

@ -2,6 +2,8 @@
global $global; global $global;
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php'; require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php';
use Pecee\SimpleRouter\SimpleRouter; //required if we want to define routes on our plugin. use Pecee\SimpleRouter\SimpleRouter; //required if we want to define routes on our plugin.
@ -96,4 +98,70 @@ class TopMenu extends PluginAbstract {
static function canAdminTopMenu(){ static function canAdminTopMenu(){
return Permissions::hasPermission(TopMenu::PERMISSION_CAN_EDIT,'TopMenu'); return Permissions::hasPermission(TopMenu::PERMISSION_CAN_EDIT,'TopMenu');
} }
public function getGalleryActionButton($videos_id) {
global $global;
$obj = $this->getDataObject();
include $global['systemRootPath'] . 'plugin/TopMenu/actionButtonGallery.php';
}
public function getNetflixActionButton($videos_id) {
global $global;
$obj = $this->getDataObject();
include $global['systemRootPath'] . 'plugin/TopMenu/actionButtonNetflix.php';
}
public function getWatchActionButton($videos_id) {
global $global, $video;
$obj = $this->getDataObject();
include $global['systemRootPath'] . 'plugin/TopMenu/actionButtonNetflix.php';
}
static function getExternalOptionName($menu_item_id){
return "menu_url_{$menu_item_id}";
}
static function setVideoMenuURL($videos_id, $menu_item_id, $url) {
$video = new Video('', '', $videos_id);
$externalOptions = _json_decode($video->getExternalOptions());
$parameterName = self::getExternalOptionName($menu_item_id);
$externalOptions->$parameterName = $url;
$video->setExternalOptions(json_encode($externalOptions));
return $video->save();
}
static function getVideoMenuURL($videos_id, $menu_item_id) {
global $_getVideoMenuURL;
if(!isset($_getVideoMenuURL)){
$_getVideoMenuURL = array();
}
if(!empty($_getVideoMenuURL[$videos_id])){
return $_getVideoMenuURL[$videos_id];
}
$video = new Video('', '', $videos_id);
$parameterName = self::getExternalOptionName($menu_item_id);
$externalOptions = _json_decode($video->getExternalOptions());
$_getVideoMenuURL[$videos_id] = $externalOptions->$parameterName;
return $_getVideoMenuURL[$videos_id];
}
public function getVideosManagerListButton() {
if (!User::canUpload()) {
return "";
}
$menu = Menu::getAllActive(Menu::$typeActionMenuCustomURL);
if(empty($menu)){
return '';
}
$obj = $this->getDataObject();
$btn = '';
$btn .= '<button type="button" class="btn btn-primary btn-light btn-sm btn-xs btn-block" onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/TopMenu/addVideoInfo.php?videos_id=\'+row.id+\'\\\');" ><i class="fas fa-edit"></i> Menu items</button>';
return $btn;
}
} }

View file

@ -0,0 +1,61 @@
<?php
$configFile = $global['systemRootPath'] . 'videos/configuration.php';
require_once $configFile;
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php';
$menu = Menu::getAllActive(Menu::$typeActionMenu);
?>
<!-- action menu start -->
<?php
foreach ($menu as $key => $value) {
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) {
?>
<div>
<a href="<?php echo $value2['finalURL']; ?>" <?php echo $value2['target']; ?> class="text-primary">
<?php
if (!empty($value2['icon'])) {
?>
<i class="<?php echo $value2['icon'] ?>"></i>
<?php
}
?>
<span class="hidden-xs">
<?php echo __($value2['title']); ?>
</span>
</a>
</div>
<?php
}
}
$menu = Menu::getAllActive(Menu::$typeActionMenuCustomURL);
foreach ($menu as $key => $value) {
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) {
$url = TopMenu::getVideoMenuURL($videos_id, $value2['id']);
if (empty($url)) {
continue;
}
?>
<div>
<a href="<?php echo $url; ?>" <?php echo $value2['target']; ?> class="text-primary">
<?php
if (!empty($value2['icon'])) {
?>
<i class="<?php echo $value2['icon'] ?>"></i>
<?php
}
?>
<span class="hidden-xs">
<?php echo __($value2['title']); ?>
</span>
</a>
</div>
<?php
}
}
?>
<!-- action menu start -->

View file

@ -0,0 +1,58 @@
<?php
$configFile = $global['systemRootPath'] . 'videos/configuration.php';
require_once $configFile;
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php';
$menu = Menu::getAllActive(Menu::$typeActionMenu);
?>
<!-- action menu start -->
<?php
foreach ($menu as $key => $value) {
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) {
?>
<a href="<?php echo $value2['finalURL']; ?>" <?php echo $value2['target']; ?> class="btn btn-default">
<?php
if (!empty($value2['icon'])) {
?>
<i class="<?php echo $value2['icon'] ?>"></i>
<?php
}
?>
<span class="hidden-xs">
<?php echo __($value2['title']); ?>
</span>
</a>
<?php
}
}
$menu = Menu::getAllActive(Menu::$typeActionMenuCustomURL);
foreach ($menu as $key => $value) {
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) {
$url = TopMenu::getVideoMenuURL($videos_id, $value2['id']);
if(empty($url)){
continue;
}
?>
<a href="<?php echo $url; ?>" <?php echo $value2['target']; ?> class="btn btn-default">
<?php
if (!empty($value2['icon'])) {
?>
<i class="<?php echo $value2['icon'] ?>"></i>
<?php
}
?>
<span class="hidden-xs">
<?php echo __($value2['title']); ?>
</span>
</a>
<?php
}
}
?>
<!-- action menu start -->

View file

@ -0,0 +1,95 @@
<?php
require_once '../../videos/configuration.php';
$videos_id = intval($_REQUEST['videos_id']);
if (empty($videos_id)) {
forbiddenPage('videos_id cannot be empty');
}
if (!Video::canEdit($videos_id)) {
forbiddenPage('You cannot edit videos_id ' . $videos_id);
}
if (!AVideoPlugin::isEnabledByName('TopMenu')) {
forbiddenPage('Plugin is disabled ');
}
$video = Video::getVideoLight($videos_id);
$img = Video::getPoster($videos_id);
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: Set Info</title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
//var_dump($video);
?>
<?php
$menu = Menu::getAllActive(Menu::$typeActionMenuCustomURL);
foreach ($menu as $key => $value) {
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) {
?>
<div class="panel panel-default">
<div class="panel-heading">
<h1>
<?php
if (!empty($value2['icon'])) {
?>
<i class="<?php echo $value2['icon'] ?>"></i>
<?php
}
?>
<?php echo __($value2['title']); ?>
</h1>
</div>
<div class="panel-body">
<input type="url" class="form-control" placeholder="https://mysitetowhiutelist.com/" id="menuURL<?php echo $value2['id']; ?>" value="<?php echo TopMenu::getVideoMenuURL($videos_id, $value2['id']); ?>"/>
</div>
<div class="panel-footer">
<button class="btn btn-block btn-success" onclick="saveMenuInfo<?php echo $value2['id']; ?>();"><i class="fas fa-solid"></i> <?php echo __('Save'); ?></button>
</div>
</div>
<script>
function saveMenuInfo<?php echo $value2['id']; ?>() {
modal.showPleaseWait();
var data = {
url: $('#menuURL<?php echo $value2['id']; ?>').val(),
menu_item_id: <?php echo $value2['id']; ?>,
videos_id: <?php echo intval($videos_id); ?>
}
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/TopMenu/addVideoInfoSave.json.php',
data: data,
type: 'post',
success: function (response) {
modal.hidePleaseWait();
if (!response.error) {
avideoAlert("<?php echo __("Congratulations!"); ?>", "", "success");
} else {
avideoAlert("<?php echo __("Error"); ?>", response.msg, "error");
}
}
});
return false;
}
</script>
<?php
}
}
?>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
</body>
</html>

View file

@ -0,0 +1,38 @@
<?php
header('Content-Type: application/json');
require_once '../../videos/configuration.php';
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$obj->videos_id = 0;
$obj->videos_id = intval($_REQUEST['videos_id']);
if (empty($obj->videos_id)) {
$obj->msg = 'You cannot edit videos_id ' . $obj->videos_id;
die(json_encode($obj));
}
$obj->menu_item_id = intval($_REQUEST['menu_item_id']);
if (empty($obj->menu_item_id)) {
$obj->msg = 'menu_item_id is empty';
die(json_encode($obj));
}
$obj->url = $_REQUEST['url'];
if (!IsValidURL($obj->url)) {
$obj->msg = 'url is invalid '.$obj->url;
die(json_encode($obj));
}
if (!Video::canEdit($obj->videos_id )) {
$obj->msg = 'You cannot edit videos_id ' . $obj->videos_id;
die(json_encode($obj));
}
$id = TopMenu::setVideoMenuURL($obj->videos_id, $obj->menu_item_id, $obj->url);
$obj->error = empty($id);
echo json_encode($obj);

View file

@ -98,8 +98,11 @@ $groups = UserGroups::getAllUsersGroups();
<div class="form-group"> <div class="form-group">
<label for="type">Type:</label> <label for="type">Type:</label>
<select class="form-control" id="type"> <select class="form-control" id="type">
<option value="1"><?php echo __('Default'); ?></option> <?php
<option value="2"><?php echo __('Left Menu'); ?></option> foreach (Menu::$typeName as $key => $value) {
echo "<option value=\"{$key}\">{$value}</option>";
}
?>
</select> </select>
</div> </div>
</div> </div>
@ -410,7 +413,7 @@ $groups = UserGroups::getAllUsersGroups();
$('#item_order').val(item.item_order); $('#item_order').val(item.item_order);
$('#item_status').val(item.status); $('#item_status').val(item.status);
$('#text').val(item.text); $('#text').val(item.text);
$('#menuSeoUrlItem').val(item.menuSeoUrlItem); $('#menuSeoUrlItem').val(item.menuSeoUrlItem);
$("#menuItemIcon").val(item.icon); $("#menuItemIcon").val(item.icon);
$("#menuItemIcon").trigger('change'); $("#menuItemIcon").trigger('change');
$('iframe').contents().find('.wysihtml5-editor').html(item.text); $('iframe').contents().find('.wysihtml5-editor').html(item.text);