<%pre>
#include <exception.h>
#include <setup.h>
#include <stringhelpers.h>
#include <tools.h>

using namespace vdrlive;

</%pre>
<%args>
  name = "channel";
  selected;
  onchange;
  bool channelid = false;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%cpp>
  if (!logged_in && LiveSetup().UseAuth()) {
    cToSvConcat targetUrl = "/login.html?redirect=";
    targetUrl.appendUrlEscaped(request.getQuery());
    return reply.redirect(targetUrl.data());
  }
</%cpp>
<select name="<$ name $>" id="<$ name $>"<?? !onchange.empty() ? cToSvConcat(" onchange=\"", onchange, "\"") ?>>
<%cpp>
  tChannelID selected_ChannelID = tChannelID::FromString(selected.c_str() );
  LOCK_CHANNELS_READ;
  for (const cChannel *listChannel = Channels->First(); listChannel; listChannel = Channels->Next(listChannel) ) {
    if (listChannel->GroupSep() || !listChannel->Name() || *listChannel->Name() == '\0') continue;
</%cpp>
    <option value="<$$ channelid ? cToSvConcat(listChannel->GetChannelID()):cToSvInt(listChannel->Number()) $>"<?? selected_ChannelID == listChannel->GetChannelID() ? " selected=\"selected\"" ?>><$$ cToSvInt(listChannel->Number()) $>: <$ listChannel->Name() $></option>
% }
</select>
