Roxen.git / server / etc / modules / Variable.pmod / module.pmod

version» Context lines:

Roxen.git/server/etc/modules/Variable.pmod/module.pmod:1: - // $Id: module.pmod,v 1.96 2006/12/06 15:57:35 grubba Exp $ + // $Id: module.pmod,v 1.97 2006/12/06 17:03:22 grubba Exp $      #include <module.h>   #include <roxen.h>      // Locale macros   //<locale-token project="roxen_config"> LOCALE </locale-token>      #define LOCALE(X,Y) \    ([string](mixed)Locale.translate("roxen_config",roxenp()->locale->get(),X,Y))   
Roxen.git/server/etc/modules/Variable.pmod/module.pmod:1129:    m->selected="selected";    selected = 1;    }    res += " "+Roxen.make_container( "option", m, _title( elem ) )+"\n";    }    if (!selected)    // Make an entry for the current value if it's not in the list,    // so no other value appears to be selected, and to ensure that    // the value doesn't change as a side-effect by another change.    res += " " + Roxen.make_container ( -  "option", (["value":_name(current), "selected": "selected"]), -  sprintf(LOCALE(332,"(keep stale value %s)"),_name(current))); +  "option", (["value": current, "selected": "selected"]), +  sprintf(LOCALE(332,"(keep stale value %s)"), current));    return res + "</select>";    }       static void create( mixed default_value, array|mapping choices,    void|int _flags, void|LocaleString std_name,    void|LocaleString std_doc )    //! Constructor.    //!    //! Choices is the list of possible choices, can be set with    //! set_choice_list at any time.
Roxen.git/server/etc/modules/Variable.pmod/module.pmod:1350:   // FIXME: Consider making a ModuleChoice as well.      //! Select a module that provides the specified interface.   class ProviderChoice   {    inherit StringChoice;    constant type = "ProviderChoice";    static Configuration conf;    static string provides;    static string default_id; -  static string local_id; +  static string local_id = "";       int low_set(RoxenModule to)    {    local_id = _name(to);    return ::low_set(to);    }       RoxenModule query()    {    RoxenModule res = ::query();    if (!res) { -  if (local_id) { +  if (local_id != "") {    // The module might have been reloaded.    // Try locating it again.    res = transform_from_form(local_id); -  } else { -  res = default_value(); +  if (res) low_set(res);    } -  if (res || local_id) low_set(res); +     }    return res;    }       array get_choice_list()    {    return conf->get_providers(provides);    }       static string _name(RoxenModule val)    {    return val?val->module_local_id():"";    }       static string _title(RoxenModule val)    { -  return val?val->query_name():""; +  return val?val->module_name:"";    }       RoxenModule transform_from_form(string local_id, mapping|void v)    {    return conf->find_module(local_id);    }       RoxenModule default_value()    {    if (default_id) {