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

version» Context lines:

Roxen.git/server/etc/modules/Variable.pmod/module.pmod:195:    constant is_variable = 1;       constant type = "Basic";    //! Mostly used for debug (sprintf( "%O", variable_obj ) uses it)       string _id = unique_prefix + "_" + (string) unique_vid++;    // used for indexing the mappings.       protected mixed _initial; // default value    protected string _path = sprintf("v%s",_id); // used for forms -  protected LocaleString __name, __doc; +  protected LocaleString __name, __doc, __group;       string diff( int render )    //! Generate a html diff of the difference between the current    //! value and the default value.    //!    //! This method is used by the configuration interface.    //!    //! The argument @[render] is used to select the operation mode.    //!    //! render=0 means that you should generate an inline diff. This
Roxen.git/server/etc/modules/Variable.pmod/module.pmod:259:    //! Only visible when devel-mode is on (default on).    //! @value VAR_INITIAL    //! Should be configured initially.    //! @value VAR_INVISIBLE    //! The variable is permanently hidden from view.    //! @endint    {    return all_flags[_id];    }    -  void set_flags( int flags ) +  this_program set_flags( int flags )    //! Set the flags for this variable.    //! Flags is a bitwise or of one or more of    //!    //! @int    //! @value VAR_EXPERT    //! Only for experts.    //! @value VAR_MORE    //! Only visible when more-mode is on (default on).    //! @value VAR_DEVELOPER    //! Only visible when devel-mode is on (default on).    //! @value VAR_INITIAL    //! Should be configured initially.    //! @value VAR_INVISIBLE    //! The variable is permanently hidden from view.    //! @endint -  +  //! +  //! @returns +  //! The object being called.    {    if(!flags )    m_delete( all_flags, _id );    else    all_flags[_id] = flags; -  +  +  return this;    }       int check_visibility( RequestID id,    int more_mode,    int expert_mode,    int devel_mode,    int initial,    int|void variable_in_cfif )    //! Check if the variable should be visible to the    //! configuration interface user.
Roxen.git/server/etc/modules/Variable.pmod/module.pmod:316:    if( (flags & VAR_EXPERT) && !expert_mode ) return 0;    if( (flags & VAR_MORE) && !more_mode ) return 0;    if( (flags & VAR_DEVELOPER) && !devel_mode ) return 0;    if( (flags & VAR_NOT_CFIF) && variable_in_cfif ) return 0;    if( (cb = get_invisibility_check_callback() ) &&    cb( id, this_object() ) )    return 0;    return 1;    }    -  void set_invisibility_check_callback( function(RequestID,Variable:int) cb ) +  this_program set_invisibility_check_callback( +  function(RequestID,Variable:int) cb )    //! If the function passed as argument returns 1, the variable    //! will not be visible in the configuration interface.    //!    //! Pass 0 to remove the invisibility callback. -  +  //! +  //! @returns +  //! The object being called.    {    if( functionp( cb ) )    invisibility_callbacks[ _id ] = cb;    else    m_delete( invisibility_callbacks, _id ); -  +  +  return this;    }       function(Variable:void) get_changed_callback( )    //! Return the callback set with set_changed_callback    {    return changed_callbacks[ _id ];    }    -  void set_changed_callback( function(Variable:void) cb ) +  this_program set_changed_callback( function(Variable:void) cb )    //! The function passed as an argument will be called    //! when the variable value is changed.    //!    //! Pass 0 to remove the callback. -  +  //! +  //! @returns +  //! The object being called.    {    if( functionp( cb ) )    changed_callbacks[ _id ] = cb;    else    m_delete( changed_callbacks, _id ); -  +  +  return this;    }    -  void add_changed_callback( function(Variable:void) cb ) +  this_program add_changed_callback( function(Variable:void) cb )    //! Add a new callback to be called when the variable is changed.    //! If set_changed_callback is called, callbacks added with this function    //! are overridden. -  +  //! +  //! @returns +  //! The object being called.    {    mixed oc = get_changed_callback( );    if( arrayp( oc ) )    oc += ({ cb });    else    oc = ({ oc, cb }) - ({ 0 });    changed_callbacks[ _id ] = oc; -  +  +  return this;    }       function(RequestID,Variable:int) get_invisibility_check_callback()    //! Return the current invisibility check callback    {    return invisibility_callbacks[_id];    }       LocaleString doc( )    //! Return the documentation for this variable (locale dependant).    //!    //! The default implementation queries the locale object in roxen    //! to get the documentation.    {    return __doc || "";    }    -  void set_doc (LocaleString doc) +  this_program set_doc (LocaleString doc)    //! Set the (locale dependent) documentation for this variable. -  +  //! +  //! @returns +  //! The object being called.    {    __doc = doc; -  +  return this;    }       LocaleString name( )    //! Return the name of this variable (locale dependant).    //!    //! The default implementation queries the locale object in roxen    //! to get the documentation.    {    return __name || LOCALE(326,"unnamed")+" "+_id;    }    -  void set_name (LocaleString name) +  this_program set_name (LocaleString name)    //! Set the (locale dependent) name for this variable. -  +  //! +  //! @returns +  //! The object being called.    {    __name = name; -  +  return this;    }    -  +  LocaleString group() +  //! Return the group, if any, of this variable (locale dependant). +  { +  return __group; +  } +  +  this_program set_group(LocaleString group) +  //! Set group for this variable to @[group]. +  //! +  //! @returns +  //! The object being called. +  { +  __group = group; +  return this; +  } +     LocaleString type_hint( )    //! Return the type hint for this variable.    //! Type hints are generic documentation for this variable type,    //! and is the same for all instances of the type.    {    }       mixed default_value()    //! The default (initial) value for this variable.    {    return _initial;    }    -  void set_default_value (mixed to) +  this_program set_default_value (mixed to)    //! Change the default value. If the variable was previously set to    //! the old default value, this will also change its actual value. -  +  //! +  //! @returns +  //! The object being called.    {    _initial = to; -  +  return this;    }    -  void set_warning( string to ) +  this_program set_warning( string to )    //! Set the warning shown in the configuration interface -  +  //! +  //! @returns +  //! The object being called.    {    if( to && strlen(to) )    all_warnings[ _id ] = to;    else    m_delete( all_warnings, _id ); -  +  +  return this;    }    -  void add_warning( string to ) +  this_program add_warning( string to )    //! Like set_warning, but adds to the current warning, if any. -  +  //! +  //! @returns +  //! The object being called.    {    if(to) set_warning( (get_warnings()||"") + to ); -  +  return this;    }       int set( mixed to )    //! Set the variable to a new value.    //! If this function returns true, the set was successful.    //! Otherwise 0 is returned. 0 is also returned if the variable was    //! not changed by the set. 1 is returned if the variable was    //! changed, and -1 is returned if the variable was changed back to    //! its default value.    //!
Roxen.git/server/etc/modules/Variable.pmod/module.pmod:613:    //!    //! Unless this variable was created by defvar(), the path is set    //! by the configuration interface the first time the variable is    //! to be shown in a form. This function can thus return 0. If it    //! does, and you still have to show the form, call set_path( )    //! with a unique string.    {    return _path;    }    -  void set_path( string to ) +  this_program set_path( string to )    //! Set the path. Not normally called from user-level code.    //!    //! This function must be called at least once before render_form    //! can be called (at least if more than one variable is to be    //! shown on the same page). This is normally done by the    //! configuration interface. -  +  //! +  //! @returns +  //! The object being called.    {    m_delete( all_variables, _path );    _path = to;    all_variables[ to ] = this_object(); -  +  return this;    }       string render_form( RequestID id, void|mapping additional_args );    //! Return a (HTML) form to change this variable. The name of all <input>    //! or similar variables should be prefixed with the value returned    //! from the path() function.       string render_view( RequestID id )    //! Return a 'view only' version of this variable.    {