Does current page contain widget or sidebar

Sidebars aren’t assigned to pages by means of, say, database entries or any other means that PHP can detect easily. Sidebars just run where a function call tells them to run. You can’t really query to see if a sidebar is on a particular page because there is nothing to query. Well, almost nothing. The only way to do this would be to load and parse your PHP template files for the presence of an appropriate call to dynamic_sidebar(). That would be quite a task.

A similar problem exists with widgets. You can find out which sidebar a widget is attached to but you have the problem, as above, of finding out where the sidebar runs.