public function get_all_folder_items(MediaURL $media_url, &$plugin_cookies) { $this->tv->folder_entered($media_url, $plugin_cookies); $this->tv->ensure_channels_loaded($plugin_cookies); $items = array(); foreach ($this->tv->get_groups() as $group) { $media_url = $group->is_favorite_channels() ? TvFavoritesScreen::get_media_url_str() : TvChannelListScreen::get_media_url_str($group->get_id()); $items[] = array(PluginRegularFolderItem::media_url => $media_url, PluginRegularFolderItem::caption => $group->get_title(), PluginRegularFolderItem::view_item_params => array(ViewItemParams::icon_path => $group->get_icon_url(), ViewItemParams::item_detailed_icon_path => $group->get_icon_url())); } $this->tv->add_special_groups($items); return $items; }
public function change_tv_favorites($fav_op_type, $channel_id, &$plugin_cookies) { $fav_channel_ids = $this->get_fav_channel_ids($plugin_cookies); if ($fav_op_type === PLUGIN_FAVORITES_OP_ADD) { array_push($fav_channel_ids, $channel_id); } else { if ($fav_op_type === PLUGIN_FAVORITES_OP_REMOVE) { $k = array_search($channel_id, $fav_channel_ids); if ($k !== false) { unset($fav_channel_ids[$k]); } } else { if ($fav_op_type === PLUGIN_FAVORITES_OP_MOVE_UP) { $k = array_search($channel_id, $fav_channel_ids); if ($k !== false && $k !== 0) { $t = $fav_channel_ids[$k - 1]; $fav_channel_ids[$k - 1] = $fav_channel_ids[$k]; $fav_channel_ids[$k] = $t; } } else { if ($fav_op_type === PLUGIN_FAVORITES_OP_MOVE_DOWN) { $k = array_search($channel_id, $fav_channel_ids); if ($k !== false && $k !== count($fav_channel_ids) - 1) { $t = $fav_channel_ids[$k + 1]; $fav_channel_ids[$k + 1] = $fav_channel_ids[$k]; $fav_channel_ids[$k] = $t; } } } } } $this->set_fav_channel_ids($plugin_cookies, $fav_channel_ids); return ActionFactory::invalidate_folders(array(TvFavoritesScreen::get_media_url_str())); }