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

Update top menu and Main Social Media Integration in user profile

This commit is contained in:
Daniel Neto 2023-08-08 12:35:31 -03:00
parent 076bdf9433
commit 4bd92c49bb
11 changed files with 799 additions and 618 deletions

1
.gitignore vendored
View file

@ -91,3 +91,4 @@ test.php
/.env
/plugin/User_Location/install/install.sql
/plugin/PedagoFlix/
/plugin/YPTWebRTC/

View file

@ -2961,7 +2961,8 @@ if (typeof gtag !== \"function\") {
return $value;
}
public static function getWebsite($users_id = '') {
public static function getSocialMediaURL($socialMedia, $users_id = '') {
global $config;
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj)) {
@ -2971,10 +2972,14 @@ if (typeof gtag !== \"function\") {
$users_id = User::getId();
}
$user = new User($users_id);
$value = $user->getExternalOptions('userWebsite');
$value = $user->getExternalOptions($socialMedia);
return $value;
}
public static function getWebsite($users_id = '') {
return self::getSocialMediaURL('website', $users_id);
}
public static function setProfilePassword($users_id, $value) {
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || !User::isAdmin()) {

View file

@ -13,6 +13,49 @@ require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_aff
class CustomizeUser extends PluginAbstract
{
public static function getSocialMedia()
{
return [
'website' => [
'class'=>'icoCopy',
'icon' => 'fas fa-globe',
'label' => __("Website"),
'placeholder' => __("Website URL"),
'isActive' => User::canUpload(),
],
'facebook' => [
'class'=>'icoFacebook',
'icon' => 'fab fa-facebook-f',
'label' => __("Facebook"),
'placeholder' => __("Facebook URL"),
'isActive' => true,
],
'twitter' => [
'class'=>'icoTwitter',
'icon' => 'fab fa-twitter',
'label' => __("Twitter"),
'placeholder' => __("Twitter URL"),
'isActive' => true,
],
'instagram' => [
'class'=>'icoInstagram',
'icon' => 'fab fa-instagram',
'label' => __("Instagram"),
'placeholder' => __("Instagram URL"),
'isActive' => true,
],
'linkedin' => [
'class'=>'icoLinkedIn',
'icon' => 'fab fa-linkedin-in',
'label' => __("LinkedIn"),
'placeholder' => __("LinkedIn URL"),
'isActive' => true,
]
];
}
public function getTags()
{
return [

View file

@ -1,32 +1,52 @@
<?php
if (User::canUpload()) {
?>
foreach (CustomizeUser::getSocialMedia() as $platform => $details) {
if (empty($details['isActive'])) {
continue;
}
?>
<div class="form-group">
<label class="col-md-4 control-label">
<?php echo __("Website"); ?>
<?php echo $details['label']; ?>
</label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-globe"></i></span>
<input id="userWebsite" placeholder="<?php echo __("Website"); ?>" class="form-control" type="url" value="<?php echo User::getWebsite(); ?>">
<span class="input-group-addon"><i class="<?php echo $details['icon']; ?>"></i></span>
<input id="user<?php echo ucfirst($platform); ?>" platform="<?php echo $platform; ?>" placeholder="<?php echo $details['placeholder']; ?>" class="form-control CustomizeUserSocialMedia" type="url" value="<?php echo User::getSocialMediaURL($platform); ?>">
</div>
</div>
</div>
<?php
}
?>
<script>
$(document).ready(function() {
$('#userWebsite').change(function (e) {
saveUserSite();
var saveTimeout;
$('.CustomizeUserSocialMedia').on('change keyup', function(e) {
clearTimeout(saveTimeout); // Clear the existing timeout
var platform = $(this).attr('platform');
var value = $(this).val();
saveTimeout = setTimeout(function() {
saveUserURL(platform, value);
}, 500);
});
});
function saveUserSite() {
var userWebsite = $('#userWebsite').val();
if(empty(userWebsite) || validURL(userWebsite)){
function saveUserURL(platform, val) {
if (empty(val) || validURL(val)) {
modal.showPleaseWait();
$.ajax({
url: webSiteRootURL + 'plugin/CustomizeUser/getMyAccount.save.json.php',
data: {userWebsite: userWebsite},
data: {
platform: platform,
val: val
},
type: 'post',
success: function(response) {
avideoResponse(response);
@ -36,6 +56,3 @@ if (User::canUpload()) {
}
}
</script>
<?php
}
?>

View file

@ -5,22 +5,41 @@ header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
if(!User::canUpload()){
$obj->msg = "Cannot Upload";
if(empty($_REQUEST['platform'])){
$obj->msg = "Platform is empty";
die(json_encode($obj));
}
$userWebsite = preg_replace('/[^a-z0-9_\/@.:?&=;%-]/i', '', @$_POST['userWebsite']);
$platform = array();
if(!empty($userWebsite) && !isValidURL($userWebsite)){
$obj->msg = "User Site is invalid {$_POST['userWebsite']} = {$userWebsite}";
foreach (CustomizeUser::getSocialMedia() as $key => $value) {
if($_REQUEST['platform'] === $key){
$platform = $value;
}
}
if(empty($platform)){
$obj->msg = "Platform {$_REQUEST['platform']} not found";
die(json_encode($obj));
}
if(empty($platform['isActive'])){
$obj->msg = "Platform is not active";
die(json_encode($obj));
}
$url = preg_replace('/[^a-z0-9_\/@.:?&=;%-]/i', '', @$_POST['val']);
if(!empty($url) && !isValidURL($url)){
$obj->msg = "URL is invalid {$_POST['url']} = {$url}";
die(json_encode($obj));
}
$cobj = AVideoPlugin::getObjectData("CustomizeUser");
$user = new User(User::getId());
$obj->added = $user->addExternalOptions('userWebsite', $userWebsite);
$obj->added = $user->addExternalOptions($_REQUEST['platform'], $url);
$obj->error = empty($obj->added);

View file

@ -5,14 +5,17 @@ $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';
$objTopMenu = AVideoPlugin::getDataObject('TopMenu');
$menu = Menu::getAllActive(Menu::$typeTopMenu);
$dropdownClass = '';
?>
<!-- right menu start -->
<?php
if (count($menu) < $objTopMenu->compactMenuIfIsGreaterThen->value) {
$dropdownClass = 'hidden-lg';
foreach ($menu as $key => $value) {
?>
<li class="dropdown">
<li class="dropdown visible-lg">
<a href="#" class=" btn btn-default btn-light navbar-btn" data-toggle="dropdown" data-toggle="tooltip" title="<?php echo $value['menuName']; ?>" data-placement="bottom">
<?php
$hiddenClass = "hidden-md hidden-sm";
@ -28,7 +31,7 @@ foreach ($menu as $key => $value) {
</span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-right" id="availableLive" style="">
<ul class="dropdown-menu dropdown-menu-right" id="availableLive">
<?php
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) {
@ -52,5 +55,37 @@ foreach ($menu as $key => $value) {
</li>
<?php
}
}
?>
<!-- This is for smaller screens (the hamburger menu) -->
<div class="<?php echo $dropdownClass; ?>">
<li class="dropdown">
<a href="#" class="btn btn-default btn-light navbar-btn" data-toggle="dropdown">
<i class="fas fa-bars"></i> <b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<?php foreach ($menu as $key => $value) : ?>
<li class="dropdown-header"><?php echo __($value['menuName']); ?></li>
<?php
$menuItems = MenuItem::getAllFromMenu($value['id'], true);
foreach ($menuItems as $key2 => $value2) :
?>
<li style="margin-right: 0;">
<a href="<?php echo $value2['finalURL']; ?>" <?php echo $value2['target']; ?>>
<?php
if (!empty($value2['icon'])) {
?>
<i class="<?php echo $value2['icon'] ?>"></i>
<?php
}
?>
<?php echo __($value2['title']); ?>
</a>
</li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</li>
</div>
<!-- right menu start -->

View file

@ -38,6 +38,14 @@ class TopMenu extends PluginAbstract {
$obj = new stdClass();
$obj->show_menu_items = true;
$o = new stdClass();
$o->type = [0=>'Do not compact top menu'];
for ($i = 1; $i <= 10; $i++) {
$o->type[$i] = "Compact top menus if it is greater then $i items";
}
$o->value = 4;
$obj->compactMenuIfIsGreaterThen = $o;
return $obj;
}

View file

@ -16,6 +16,7 @@ $groups = UserGroups::getAllUsersGroups();
?>
<!DOCTYPE html>
<html lang="<?php echo getLanguage(); ?>">
<head>
<title><?php echo __("Top Menu") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title>
<?php
@ -28,14 +29,17 @@ $groups = UserGroups::getAllUsersGroups();
margin: 2px;
padding: 5px;
}
#sortable {
padding: 0;
}
.ui-state-highlight {
height: 30px;
}
</style>
</head>
<body class="<?php echo $global['bodyClass']; ?> ">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
@ -122,17 +126,19 @@ $groups = UserGroups::getAllUsersGroups();
<div class="panel panel-default">
<div class="panel-heading">Menus Available</div>
<div class="panel-body">
<table id="example" class="display table table-striped table-hover" width="100%" cellspacing="0">
<table id="topMenuGrid" class="display table table-striped table-hover" width="100%" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>Type</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Status</th>
<th>Type</th>
</tr>
</tfoot>
</table>
@ -273,6 +279,7 @@ $groups = UserGroups::getAllUsersGroups();
?>
<script type="text/javascript" src="<?php echo getCDN(); ?>view/css/DataTables/datatables.min.js"></script>
<script>
var typeName = <?php echo json_encode(Menu::$typeName); ?>;
var currentItem = [];
function checkIfHasId() {
@ -462,11 +469,20 @@ $groups = UserGroups::getAllUsersGroups();
$('#pageType').trigger('change');
var table = $('#example').DataTable({
var table = $('#topMenuGrid').DataTable({
"ajax": webSiteRootURL + "plugin/TopMenu/menus.json.php",
"columns": [
{"data": "menuName"},
{"data": "status"}
"columns": [{
"data": "menuName"
},
{
"data": "status"
},
{
"data": "type",
"render": function(data, type, row, meta) {
return typeName[data] || data;
}
}
],
select: true,
@ -479,7 +495,7 @@ $groups = UserGroups::getAllUsersGroups();
clearMenuItemForm();
});
$('#example tbody').on('click', 'tr', function () {
$('#topMenuGrid tbody').on('click', 'tr', function() {
var data = table.row(this).data();
console.log(data);
$('#menuId').val(data.id);
@ -579,4 +595,5 @@ $groups = UserGroups::getAllUsersGroups();
});
</script>
</body>
</html>

BIN
view/.rnd Normal file

Binary file not shown.

View file

@ -93,35 +93,44 @@ $showChannelProgramsTab = $advancedCustomUser->showChannelProgramsTab && !empty(
transition: max-height 0.25s ease-out;
overflow: hidden;
}
#aboutAreaPreContent {
margin-bottom: 30px;
}
#aboutArea.expanded #aboutAreaPreContent {
max-height: 1500px;
overflow: auto;
transition: max-height 0.25s ease-in;
}
#aboutAreaShowMoreBtn {
position: absolute;
bottom: 0;
}
#aboutArea .showMore {
display: block;
}
#aboutArea .showLess {
display: none;
}
#aboutArea.expanded .showMore {
display: none;
}
#aboutArea.expanded .showLess {
display: block;
}
#channelHome {
background-color: rgb(<?php echo $obj->backgroundRGB; ?>);
position: relative;
overflow: hidden;
}
.feedDropdown {
margin-right: 4px;
}
@ -178,6 +187,29 @@ $showChannelProgramsTab = $advancedCustomUser->showChannelProgramsTab && !empty(
<?php
echo User::getEmailVerifiedIcon($user_id)
?></h2>
<?php
$socialMedia = CustomizeUser::getSocialMedia();
?>
<ul class="social-network social-circle">
<?php
foreach ($socialMedia as $platform => $details) {
if ($details['isActive']) {
$url = User::getSocialMediaURL($platform, $user_id);
if (!empty($url)) {
?>
<li>
<a href="<?php echo $url; ?>" target="_blank" class="<?php echo $details['class']; ?>" title="<?php echo $details['label']; ?>" data-toggle="tooltip">
<i class="<?php echo $details['icon']; ?>"></i>
</a>
</li>
<?php
}
}
}
?>
</ul>
<span class="pull-right">
<?php
echo getUserOnlineLabel($user_id, 'pull-right', 'padding: 0 5px;');
@ -334,9 +366,11 @@ $showChannelProgramsTab = $advancedCustomUser->showChannelProgramsTab && !empty(
}
$obj = AVideoPlugin::getObjectData("YouPHPFlix2");
?>
<style>#bigVideo{
<style>
#bigVideo {
top: 0 !important;
}</style>
}
</style>
<div class="tab-pane <?php echo $active; ?>" id="channelHome">
<?php
$obj->BigVideo = true;

View file

@ -24,7 +24,9 @@ ul.social-network li {
.social-network a.icoWhatsapp:hover {
background-color: #25D366;
}
.social-network a.icoInstagram:hover {
background-color: #E4405F;
}
.social-network a.icoFacebook:hover {
background-color: #3B5998;
}