def generate_page_list(max_page, current_page, max_displayed_pages):
    """ Generates a list of elements for the pagination

    Content of returned list may look like this:
    [1, '...', 50, 51, 52, 53, 54, '...', 3210]
    or
    [1, 2, 3]

    Args:
        max_page: The maximum page available for the search results
        current_page: The current page number
        max_displayed_pages: How many pages before and after the current shall be displayed until '...' is showed
    Returns:
        list: Contains all page elements
    """
    final_list = []
    if max_page >= 0:
        # add the first page, it should always be there if we have at least one page
        final_list.append(1)
        available_pages = range(current_page - max_displayed_pages, current_page + max_displayed_pages)
        if 1 not in available_pages:
            final_list.append("...")
        for page in available_pages:
            # iterate over the 'pageregion' around our current page. Add the page numbers if they are logically valid
            if page > 0 and page <= max_page and page not in final_list:
                final_list.append(page)
        if max_page > final_list[len(final_list) - 1] and max_page not in final_list:
            # if we didn't reach the max_page yet in our 'pageregion', we need to add it to the list
            if max_page > final_list[len(final_list) - 1] + 1:
                final_list.append("...")
            final_list.append(max_page)
    return final_list