diff --git a/plugin/TopMenu/Objects/Menu.php b/plugin/TopMenu/Objects/Menu.php index 103f794dd..cf7672ab1 100644 --- a/plugin/TopMenu/Objects/Menu.php +++ b/plugin/TopMenu/Objects/Menu.php @@ -1,123 +1,125 @@ 'Left', 2=>'Top', 3=>'Action', - 4=>'Action Custom URL Per Video', - 5=>'Action Custom URL Per Video For Logged Users Only', - 6=>'Action Custom URL Per Video For Users That can Watch Video'); + 4=>'Action Per Video', + 5=>'Action Per Video For Logged Users Only', + 6=>'Action Per Video For Users That can Watch Video', + 7=>'Action Per Video For Users That can NOT Watch Video'); protected $id, $menuName, $categories_id, $users_groups_id, $menu_order, $status, $position, $type, $icon, $menuSeoUrl; static function getSearchFieldsNames() { return array(); } static function getTableName() { return 'topMenu'; } function setMenuName($menuName) { $this->menuName = $menuName; } function setCategories_id($categories_id) { $this->categories_id = $categories_id; } function setUsers_groups_id($users_groups_id) { $this->users_groups_id = $users_groups_id; } function setMenu_order($menu_order) { $this->menu_order = $menu_order; } function setStatus($status) { $this->status = $status; } function setPosition($position) { $this->position = $position; } function setType($type) { $this->type = $type; } function setIcon($icon) { $this->icon = $icon; } function setmenuSeoUrl($menuSeoUrl){ $this->menuSeoUrl=$menuSeoUrl; } static function getAllActive($type=false) { global $global; $sql = "SELECT * FROM ".static::getTableName()." WHERE status = 'active' "; if(!empty($type)){ $sql .= " AND type = $type "; } $sql .= " ORDER BY menu_order "; _mysql_connect(); $res = $global['mysqli']->query($sql); $rows = array(); if ($res) { while ($row = $res->fetch_assoc()) { $rows[] = $row; } } return $rows; } function save() { global $global; if(empty($this->menuName)){ $this->menuName = 'Unknow Menu Name'; } if(empty($this->categories_id)){ $this->categories_id = 'null'; } if(empty($this->users_groups_id)){ $this->users_groups_id = 'null'; } if(empty($this->menu_order)){ $this->menu_order = 0; } if(empty($this->status)){ $this->status = "active"; } if(empty($this->position)){ $this->position = "right"; } if(empty($this->type)){ $this->type = 1; } if(empty($this->menuSeoUrl)){ $this->menuSeoUrl=$this->menuName; } $this->menuSeoUrl=$global['mysqli']->real_escape_string(preg_replace('/[^a-z0-9]+/', '_', strtolower($this->menuSeoUrl))); return parent::save(); } } diff --git a/plugin/TopMenu/TopMenu.php b/plugin/TopMenu/TopMenu.php index 554f7a6c4..e281d32f7 100644 --- a/plugin/TopMenu/TopMenu.php +++ b/plugin/TopMenu/TopMenu.php @@ -1,163 +1,164 @@ Help"; return $txt.$help; } public function getName() { return "TopMenu"; } public function getUUID() { return "2e7866ed-2e02-4136-bec6-4cd90754e3a2"; } public function getPluginVersion() { return "2.1"; } public function updateScript() { global $mysqlDatabase; //update version 2.0 $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? and COLUMN_NAME=?"; $res = sqlDAL::readSql($sql,"s",array($mysqlDatabase, "topMenu_items", "menuSeoUrlItem")); $menuSeoUrlItem=sqlDAL::fetchAssoc($res); if(!$menuSeoUrlItem){ sqlDal::writeSql("alter table topMenu_items add menuSeoUrlItem varchar(255) default ''"); } return true; } public function addRoutes() { global $basePath; SimpleRouter::get($basePath."/menu/{menuSeoUrlItem}", function($menuSeoUrlItem) { $_GET['menuSeoUrlItem']=$menuSeoUrlItem; require_once "plugin/TopMenu/seo.php"; },['defaultParameterRegex' => '.*']); return false; } public function getHeadCode() { global $global; $css = ''; return $css; } public function getHTMLMenuRight() { global $global; include $global['systemRootPath'] . 'plugin/TopMenu/HTMLMenuRight.php'; } public function getPluginMenu() { global $global; $filename = $global['systemRootPath'] . 'plugin/TopMenu/pluginMenu.html'; return file_get_contents($filename); } public function getHTMLMenuLeft() { global $global; include $global['systemRootPath'] . 'plugin/TopMenu/HTMLMenuLeft.php'; } public function getidBySeoUrl($menuSeoUrlItem) { global $global; $sql="select id from topMenu_items where menuSeoUrlItem= ?"; $res=sqlDal::readSql($sql, "s", array($global['mysqli']->real_escape_string($menuSeoUrlItem))); $menuId=sqlDAL::fetchAssoc($res); if(!isset($menuId['id'])) return false; return $menuId['id']; } function getPermissionsOptions(){ $permissions = array(); $permissions[] = new PluginPermissionOption(TopMenu::PERMISSION_CAN_EDIT, __("TopMenu"), __("Can edit TopMenu plugin"), 'TopMenu'); return $permissions; } static function canAdminTopMenu(){ 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]; + $index = "{$videos_id}_{$menu_item_id}"; + if(!empty($_getVideoMenuURL[$index])){ + return $_getVideoMenuURL[$index]; } $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]; + $_getVideoMenuURL[$index] = $externalOptions->$parameterName; + return $_getVideoMenuURL[$index]; } public function getVideosManagerListButton() { if (!User::canUpload()) { return ""; } $obj = $this->getDataObject(); $btn = ''; $btn .= ''; return $btn; } } diff --git a/plugin/TopMenu/actionButtonGallery.php b/plugin/TopMenu/actionButtonGallery.php index 1f9bbad91..8db967c81 100644 --- a/plugin/TopMenu/actionButtonGallery.php +++ b/plugin/TopMenu/actionButtonGallery.php @@ -1,117 +1,146 @@ $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { ?>
$value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); if (empty($url)) { continue; } ?> $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); if (empty($url)) { continue; } ?> $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); if (empty($url)) { continue; } ?> $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); + if (empty($url)) { + continue; + } + ?> + + \ No newline at end of file diff --git a/plugin/TopMenu/actionButtonNetflix.php b/plugin/TopMenu/actionButtonNetflix.php index c6cda65ec..5e8847ce8 100644 --- a/plugin/TopMenu/actionButtonNetflix.php +++ b/plugin/TopMenu/actionButtonNetflix.php @@ -1,111 +1,138 @@ $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { ?> class="btn btn-default no-outline"> $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); if (empty($url)) { continue; } ?> class="btn btn-default no-outline"> $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); if (empty($url)) { continue; } ?> class="btn btn-default no-outline"> $value) { $menuItems = MenuItem::getAllFromMenu($value['id'], true); foreach ($menuItems as $key2 => $value2) { $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); if (empty($url)) { continue; } ?> class="btn btn-default no-outline"> $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); + if (empty($url)) { + continue; + } + ?> + class="btn btn-default no-outline"> + + + + + + diff --git a/plugin/TopMenu/addVideoInfo.php b/plugin/TopMenu/addVideoInfo.php index bad3c404f..96c10adad 100644 --- a/plugin/TopMenu/addVideoInfo.php +++ b/plugin/TopMenu/addVideoInfo.php @@ -1,213 +1,108 @@ $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + ?> +